Update auto-generated TypeScript Bindings
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
27 #define DO_ASSERT(a) (void)(a)
28 #define CHECK(a)
29 #define CHECK_ACCESS(p)
30 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
31
32 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
33 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
36
37 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
38
39 #define DECL_ARR_TYPE(ty, name) \
40         struct name##array { \
41                 uint32_t arr_len; \
42                 ty elems[]; \
43         }; \
44         typedef struct name##array * name##Array; \
45         static inline name##Array init_##name##Array(size_t arr_len) { \
46                 name##Array arr = (name##Array)MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), "##name array init"); \
47                 arr->arr_len = arr_len; \
48                 return arr; \
49         }
50
51 DECL_ARR_TYPE(int64_t, int64_t);
52 DECL_ARR_TYPE(int8_t, int8_t);
53 DECL_ARR_TYPE(uint32_t, uint32_t);
54 DECL_ARR_TYPE(void*, ptr);
55 DECL_ARR_TYPE(char, char);
56 typedef charArray jstring;
57
58 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
59         charArray arr = init_charArray(len);
60         memcpy(arr->elems, chars, len);
61         return arr;
62 }
63 static inline LDKStr str_ref_to_owned_c(const jstring str) {
64         char* newchars = MALLOC(str->arr_len + 1, "String chars");
65         memcpy(newchars, str->elems, str->arr_len);
66         newchars[str->arr_len] = 0;
67         LDKStr res = {
68                 .chars = newchars,
69                 .len = str->arr_len,
70                 .chars_is_owned = true
71         };
72         return res;
73 }
74
75 typedef bool jboolean;
76
77 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
78         return (uint32_t)MALLOC(size, "JS-Called malloc");
79 }
80 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
81         FREE((void*)ptr);
82 }
83 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
84 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
85         switch (ord) {
86                 case 0: return LDKAccessError_UnknownChain;
87                 case 1: return LDKAccessError_UnknownTx;
88         }
89         abort();
90 }
91 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
92         switch (val) {
93                 case LDKAccessError_UnknownChain: return 0;
94                 case LDKAccessError_UnknownTx: return 1;
95                 default: abort();
96         }
97 }
98 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
99         switch (ord) {
100                 case 0: return LDKCOption_NoneZ_Some;
101                 case 1: return LDKCOption_NoneZ_None;
102         }
103         abort();
104 }
105 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
106         switch (val) {
107                 case LDKCOption_NoneZ_Some: return 0;
108                 case LDKCOption_NoneZ_None: return 1;
109                 default: abort();
110         }
111 }
112 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
113         switch (ord) {
114                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
115                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
116         }
117         abort();
118 }
119 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
120         switch (val) {
121                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
122                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
123                 default: abort();
124         }
125 }
126 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
127         switch (ord) {
128                 case 0: return LDKConfirmationTarget_Background;
129                 case 1: return LDKConfirmationTarget_Normal;
130                 case 2: return LDKConfirmationTarget_HighPriority;
131         }
132         abort();
133 }
134 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
135         switch (val) {
136                 case LDKConfirmationTarget_Background: return 0;
137                 case LDKConfirmationTarget_Normal: return 1;
138                 case LDKConfirmationTarget_HighPriority: return 2;
139                 default: abort();
140         }
141 }
142 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
143         switch (ord) {
144                 case 0: return LDKLevel_Gossip;
145                 case 1: return LDKLevel_Trace;
146                 case 2: return LDKLevel_Debug;
147                 case 3: return LDKLevel_Info;
148                 case 4: return LDKLevel_Warn;
149                 case 5: return LDKLevel_Error;
150         }
151         abort();
152 }
153 static inline int32_t LDKLevel_to_js(LDKLevel val) {
154         switch (val) {
155                 case LDKLevel_Gossip: return 0;
156                 case LDKLevel_Trace: return 1;
157                 case LDKLevel_Debug: return 2;
158                 case LDKLevel_Info: return 3;
159                 case LDKLevel_Warn: return 4;
160                 case LDKLevel_Error: return 5;
161                 default: abort();
162         }
163 }
164 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
165         switch (ord) {
166                 case 0: return LDKNetwork_Bitcoin;
167                 case 1: return LDKNetwork_Testnet;
168                 case 2: return LDKNetwork_Regtest;
169                 case 3: return LDKNetwork_Signet;
170         }
171         abort();
172 }
173 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
174         switch (val) {
175                 case LDKNetwork_Bitcoin: return 0;
176                 case LDKNetwork_Testnet: return 1;
177                 case LDKNetwork_Regtest: return 2;
178                 case LDKNetwork_Signet: return 3;
179                 default: abort();
180         }
181 }
182 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
183         switch (ord) {
184                 case 0: return LDKSecp256k1Error_IncorrectSignature;
185                 case 1: return LDKSecp256k1Error_InvalidMessage;
186                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
187                 case 3: return LDKSecp256k1Error_InvalidSignature;
188                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
189                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
190                 case 6: return LDKSecp256k1Error_InvalidTweak;
191                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
192                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
193         }
194         abort();
195 }
196 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
197         switch (val) {
198                 case LDKSecp256k1Error_IncorrectSignature: return 0;
199                 case LDKSecp256k1Error_InvalidMessage: return 1;
200                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
201                 case LDKSecp256k1Error_InvalidSignature: return 3;
202                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
203                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
204                 case LDKSecp256k1Error_InvalidTweak: return 6;
205                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
206                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
207                 default: abort();
208         }
209 }
210 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
211         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
212         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
213         return ret;
214 }
215 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) {
216         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
217         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
218         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
219         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
220         CVec_u8Z_free(ret_var);
221         return ret_arr;
222 }
223
224 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) {
225         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
226         int64_t ret_val = TxOut_get_value(thing_conv);
227         return ret_val;
228 }
229
230 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
231 CHECK(owner->result_ok);
232         return ChannelConfig_clone(&*owner->contents.result);
233 }
234 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
235         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
236         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
237         uint64_t ret_ref = 0;
238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
241         ret_ref = (uint64_t)ret_var.inner;
242         if (ret_var.is_owned) {
243                 ret_ref |= 1;
244         }
245         return ret_ref;
246 }
247
248 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
249 CHECK(!owner->result_ok);
250         return DecodeError_clone(&*owner->contents.err);
251 }
252 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
253         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
254         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
255         uint64_t ret_ref = 0;
256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
259         ret_ref = (uint64_t)ret_var.inner;
260         if (ret_var.is_owned) {
261                 ret_ref |= 1;
262         }
263         return ret_ref;
264 }
265
266 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
267 CHECK(owner->result_ok);
268         return OutPoint_clone(&*owner->contents.result);
269 }
270 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
271         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
272         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
273         uint64_t ret_ref = 0;
274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
277         ret_ref = (uint64_t)ret_var.inner;
278         if (ret_var.is_owned) {
279                 ret_ref |= 1;
280         }
281         return ret_ref;
282 }
283
284 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
285 CHECK(!owner->result_ok);
286         return DecodeError_clone(&*owner->contents.err);
287 }
288 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
289         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
290         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
291         uint64_t ret_ref = 0;
292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
295         ret_ref = (uint64_t)ret_var.inner;
296         if (ret_var.is_owned) {
297                 ret_ref |= 1;
298         }
299         return ret_ref;
300 }
301
302 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
303 CHECK(owner->result_ok);
304         return *owner->contents.result;
305 }
306 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
307         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
308         int8_tArray ret_arr = init_int8_tArray(32);
309         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
310         return ret_arr;
311 }
312
313 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
314 CHECK(!owner->result_ok);
315         return *owner->contents.err;
316 }
317 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
318         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
319         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
320         return ret_conv;
321 }
322
323 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
324 CHECK(owner->result_ok);
325         return *owner->contents.result;
326 }
327 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
328         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
329         int8_tArray ret_arr = init_int8_tArray(33);
330         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
331         return ret_arr;
332 }
333
334 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
335 CHECK(!owner->result_ok);
336         return *owner->contents.err;
337 }
338 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
339         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
340         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
341         return ret_conv;
342 }
343
344 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
345 CHECK(owner->result_ok);
346         return TxCreationKeys_clone(&*owner->contents.result);
347 }
348 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
349         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
350         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
351         uint64_t ret_ref = 0;
352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
355         ret_ref = (uint64_t)ret_var.inner;
356         if (ret_var.is_owned) {
357                 ret_ref |= 1;
358         }
359         return ret_ref;
360 }
361
362 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
363 CHECK(!owner->result_ok);
364         return DecodeError_clone(&*owner->contents.err);
365 }
366 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
367         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
368         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
369         uint64_t ret_ref = 0;
370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
373         ret_ref = (uint64_t)ret_var.inner;
374         if (ret_var.is_owned) {
375                 ret_ref |= 1;
376         }
377         return ret_ref;
378 }
379
380 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
381 CHECK(owner->result_ok);
382         return ChannelPublicKeys_clone(&*owner->contents.result);
383 }
384 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
385         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
386         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
387         uint64_t ret_ref = 0;
388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
391         ret_ref = (uint64_t)ret_var.inner;
392         if (ret_var.is_owned) {
393                 ret_ref |= 1;
394         }
395         return ret_ref;
396 }
397
398 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
399 CHECK(!owner->result_ok);
400         return DecodeError_clone(&*owner->contents.err);
401 }
402 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
403         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
404         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
405         uint64_t ret_ref = 0;
406         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
407         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
409         ret_ref = (uint64_t)ret_var.inner;
410         if (ret_var.is_owned) {
411                 ret_ref |= 1;
412         }
413         return ret_ref;
414 }
415
416 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
417 CHECK(owner->result_ok);
418         return TxCreationKeys_clone(&*owner->contents.result);
419 }
420 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
421         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
422         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
423         uint64_t ret_ref = 0;
424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
427         ret_ref = (uint64_t)ret_var.inner;
428         if (ret_var.is_owned) {
429                 ret_ref |= 1;
430         }
431         return ret_ref;
432 }
433
434 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
435 CHECK(!owner->result_ok);
436         return *owner->contents.err;
437 }
438 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
439         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
440         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
441         return ret_conv;
442 }
443
444 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
445         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
446         switch(obj->tag) {
447                 case LDKCOption_u32Z_Some: return 0;
448                 case LDKCOption_u32Z_None: return 1;
449                 default: abort();
450         }
451 }
452 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
453         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
454         assert(obj->tag == LDKCOption_u32Z_Some);
455         return obj->some;
456 }
457 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
458 CHECK(owner->result_ok);
459         return HTLCOutputInCommitment_clone(&*owner->contents.result);
460 }
461 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
462         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
463         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
464         uint64_t ret_ref = 0;
465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
468         ret_ref = (uint64_t)ret_var.inner;
469         if (ret_var.is_owned) {
470                 ret_ref |= 1;
471         }
472         return ret_ref;
473 }
474
475 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
476 CHECK(!owner->result_ok);
477         return DecodeError_clone(&*owner->contents.err);
478 }
479 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
480         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
481         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
482         uint64_t ret_ref = 0;
483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
486         ret_ref = (uint64_t)ret_var.inner;
487         if (ret_var.is_owned) {
488                 ret_ref |= 1;
489         }
490         return ret_ref;
491 }
492
493 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
494 CHECK(owner->result_ok);
495         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
496 }
497 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
498         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
499         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
500         uint64_t ret_ref = 0;
501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
504         ret_ref = (uint64_t)ret_var.inner;
505         if (ret_var.is_owned) {
506                 ret_ref |= 1;
507         }
508         return ret_ref;
509 }
510
511 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
512 CHECK(!owner->result_ok);
513         return DecodeError_clone(&*owner->contents.err);
514 }
515 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
516         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
517         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
518         uint64_t ret_ref = 0;
519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
522         ret_ref = (uint64_t)ret_var.inner;
523         if (ret_var.is_owned) {
524                 ret_ref |= 1;
525         }
526         return ret_ref;
527 }
528
529 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
530 CHECK(owner->result_ok);
531         return ChannelTransactionParameters_clone(&*owner->contents.result);
532 }
533 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
534         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
535         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
536         uint64_t ret_ref = 0;
537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
540         ret_ref = (uint64_t)ret_var.inner;
541         if (ret_var.is_owned) {
542                 ret_ref |= 1;
543         }
544         return ret_ref;
545 }
546
547 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
548 CHECK(!owner->result_ok);
549         return DecodeError_clone(&*owner->contents.err);
550 }
551 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
552         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
553         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
554         uint64_t ret_ref = 0;
555         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
556         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
558         ret_ref = (uint64_t)ret_var.inner;
559         if (ret_var.is_owned) {
560                 ret_ref |= 1;
561         }
562         return ret_ref;
563 }
564
565 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
566 CHECK(owner->result_ok);
567         return HolderCommitmentTransaction_clone(&*owner->contents.result);
568 }
569 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
570         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
571         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
572         uint64_t ret_ref = 0;
573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
576         ret_ref = (uint64_t)ret_var.inner;
577         if (ret_var.is_owned) {
578                 ret_ref |= 1;
579         }
580         return ret_ref;
581 }
582
583 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
584 CHECK(!owner->result_ok);
585         return DecodeError_clone(&*owner->contents.err);
586 }
587 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
588         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
589         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
590         uint64_t ret_ref = 0;
591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
594         ret_ref = (uint64_t)ret_var.inner;
595         if (ret_var.is_owned) {
596                 ret_ref |= 1;
597         }
598         return ret_ref;
599 }
600
601 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
602 CHECK(owner->result_ok);
603         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
604 }
605 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
606         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
607         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
608         uint64_t ret_ref = 0;
609         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
610         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
612         ret_ref = (uint64_t)ret_var.inner;
613         if (ret_var.is_owned) {
614                 ret_ref |= 1;
615         }
616         return ret_ref;
617 }
618
619 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
620 CHECK(!owner->result_ok);
621         return DecodeError_clone(&*owner->contents.err);
622 }
623 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
624         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
625         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
626         uint64_t ret_ref = 0;
627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
630         ret_ref = (uint64_t)ret_var.inner;
631         if (ret_var.is_owned) {
632                 ret_ref |= 1;
633         }
634         return ret_ref;
635 }
636
637 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
638 CHECK(owner->result_ok);
639         return &*owner->contents.result;
640 }
641 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
642         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
643         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
644         uint64_t ret_ref = 0;
645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
648         ret_ref = (uint64_t)ret_var.inner & ~1;
649         return ret_ref;
650 }
651
652 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
653 CHECK(!owner->result_ok);
654         return *owner->contents.err;
655 }
656 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
657         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
658         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
659 }
660
661 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
662 CHECK(owner->result_ok);
663         return CommitmentTransaction_clone(&*owner->contents.result);
664 }
665 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
666         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
667         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
668         uint64_t ret_ref = 0;
669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
672         ret_ref = (uint64_t)ret_var.inner;
673         if (ret_var.is_owned) {
674                 ret_ref |= 1;
675         }
676         return ret_ref;
677 }
678
679 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
680 CHECK(!owner->result_ok);
681         return DecodeError_clone(&*owner->contents.err);
682 }
683 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
684         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
685         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
686         uint64_t ret_ref = 0;
687         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
688         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
690         ret_ref = (uint64_t)ret_var.inner;
691         if (ret_var.is_owned) {
692                 ret_ref |= 1;
693         }
694         return ret_ref;
695 }
696
697 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
698 CHECK(owner->result_ok);
699         return &*owner->contents.result;
700 }
701 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
702         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
703         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
704         uint64_t ret_ref = 0;
705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
708         ret_ref = (uint64_t)ret_var.inner & ~1;
709         return ret_ref;
710 }
711
712 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
713 CHECK(!owner->result_ok);
714         return *owner->contents.err;
715 }
716 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
717         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
718         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
719 }
720
721 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
722 CHECK(owner->result_ok);
723         return *owner->contents.result;
724 }
725 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
726         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
727         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
728         ptrArray ret_arr = NULL;
729         ret_arr = init_ptrArray(ret_var.datalen);
730         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
731         for (size_t m = 0; m < ret_var.datalen; m++) {
732                 int8_tArray ret_conv_12_arr = init_int8_tArray(64);
733                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
734                 ret_arr_ptr[m] = ret_conv_12_arr;
735         }
736         
737         return ret_arr;
738 }
739
740 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
741 CHECK(!owner->result_ok);
742         return *owner->contents.err;
743 }
744 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
745         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
746         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
747 }
748
749 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
750 CHECK(owner->result_ok);
751         return ShutdownScript_clone(&*owner->contents.result);
752 }
753 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
754         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
755         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
756         uint64_t ret_ref = 0;
757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
760         ret_ref = (uint64_t)ret_var.inner;
761         if (ret_var.is_owned) {
762                 ret_ref |= 1;
763         }
764         return ret_ref;
765 }
766
767 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
768 CHECK(!owner->result_ok);
769         return DecodeError_clone(&*owner->contents.err);
770 }
771 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
772         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
773         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
774         uint64_t ret_ref = 0;
775         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
776         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
778         ret_ref = (uint64_t)ret_var.inner;
779         if (ret_var.is_owned) {
780                 ret_ref |= 1;
781         }
782         return ret_ref;
783 }
784
785 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
786 CHECK(owner->result_ok);
787         return ShutdownScript_clone(&*owner->contents.result);
788 }
789 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
790         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
791         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
792         uint64_t ret_ref = 0;
793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
796         ret_ref = (uint64_t)ret_var.inner;
797         if (ret_var.is_owned) {
798                 ret_ref |= 1;
799         }
800         return ret_ref;
801 }
802
803 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
804 CHECK(!owner->result_ok);
805         return InvalidShutdownScript_clone(&*owner->contents.err);
806 }
807 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
808         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
809         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
810         uint64_t ret_ref = 0;
811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
814         ret_ref = (uint64_t)ret_var.inner;
815         if (ret_var.is_owned) {
816                 ret_ref |= 1;
817         }
818         return ret_ref;
819 }
820
821 typedef struct LDKType_JCalls {
822         atomic_size_t refcnt;
823         uint32_t instance_ptr;
824 } LDKType_JCalls;
825 static void LDKType_JCalls_free(void* this_arg) {
826         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
827         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
828                 FREE(j_calls);
829         }
830 }
831 uint16_t type_id_LDKType_jcall(const void* this_arg) {
832         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
833         return js_invoke_function_0(j_calls->instance_ptr, 0);
834 }
835 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
836         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
837         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 1);
838         LDKStr ret_conv = str_ref_to_owned_c(ret);
839         return ret_conv;
840 }
841 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
842         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
843         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 2);
844         LDKCVec_u8Z ret_ref;
845         ret_ref.datalen = ret->arr_len;
846         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
847         memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
848         return ret_ref;
849 }
850 static void LDKType_JCalls_cloned(LDKType* new_obj) {
851         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
852         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
853 }
854 static inline LDKType LDKType_init (JSValue o) {
855         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
856         atomic_init(&calls->refcnt, 1);
857         calls->instance_ptr = o;
858
859         LDKType ret = {
860                 .this_arg = (void*) calls,
861                 .type_id = type_id_LDKType_jcall,
862                 .debug_str = debug_str_LDKType_jcall,
863                 .write = write_LDKType_jcall,
864                 .cloned = LDKType_JCalls_cloned,
865                 .free = LDKType_JCalls_free,
866         };
867         return ret;
868 }
869 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
870         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
871         *res_ptr = LDKType_init(o);
872         return (long)res_ptr;
873 }
874 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
875         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
876         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
877         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
878         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
879         return ret_val;
880 }
881
882 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
883         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
884         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
885         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
886         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
887         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
888         Str_free(ret_str);
889         return ret_conv;
890 }
891
892 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
893         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
894         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
895         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
896         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
897         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
898         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
899         CVec_u8Z_free(ret_var);
900         return ret_arr;
901 }
902
903 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
904         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
905         switch(obj->tag) {
906                 case LDKCOption_TypeZ_Some: return 0;
907                 case LDKCOption_TypeZ_None: return 1;
908                 default: abort();
909         }
910 }
911 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
912         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
913         assert(obj->tag == LDKCOption_TypeZ_Some);
914                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
915                         *some_ret = Type_clone(&obj->some);
916         return (uint64_t)some_ret;
917 }
918 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
919 CHECK(owner->result_ok);
920         return COption_TypeZ_clone(&*owner->contents.result);
921 }
922 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
923         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
924         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
925         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
926         uint64_t ret_ref = (uint64_t)ret_copy;
927         return ret_ref;
928 }
929
930 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
931 CHECK(!owner->result_ok);
932         return DecodeError_clone(&*owner->contents.err);
933 }
934 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
935         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
936         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
937         uint64_t ret_ref = 0;
938         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
939         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
941         ret_ref = (uint64_t)ret_var.inner;
942         if (ret_var.is_owned) {
943                 ret_ref |= 1;
944         }
945         return ret_ref;
946 }
947
948 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
949 CHECK(owner->result_ok);
950         return *owner->contents.result;
951 }
952 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
953         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
954         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
955         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
956         return ret_conv;
957 }
958
959 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
960 CHECK(!owner->result_ok);
961         return *owner->contents.err;
962 }
963 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
964         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
965         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
966         return ret_conv;
967 }
968
969 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
970 CHECK(owner->result_ok);
971         return ChannelMonitorUpdate_clone(&*owner->contents.result);
972 }
973 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
974         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
975         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
976         uint64_t ret_ref = 0;
977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
980         ret_ref = (uint64_t)ret_var.inner;
981         if (ret_var.is_owned) {
982                 ret_ref |= 1;
983         }
984         return ret_ref;
985 }
986
987 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
988 CHECK(!owner->result_ok);
989         return DecodeError_clone(&*owner->contents.err);
990 }
991 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
992         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
993         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
994         uint64_t ret_ref = 0;
995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
998         ret_ref = (uint64_t)ret_var.inner;
999         if (ret_var.is_owned) {
1000                 ret_ref |= 1;
1001         }
1002         return ret_ref;
1003 }
1004
1005 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1006         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1007         switch(obj->tag) {
1008                 case LDKMonitorEvent_HTLCEvent: return 0;
1009                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1010                 case LDKMonitorEvent_UpdateCompleted: return 2;
1011                 case LDKMonitorEvent_UpdateFailed: return 3;
1012                 default: abort();
1013         }
1014 }
1015 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1016         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1017         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1018                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1019                         uint64_t htlc_event_ref = 0;
1020                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1021                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1022                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1023                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1024         return htlc_event_ref;
1025 }
1026 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1027         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1028         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1029                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1030                         uint64_t commitment_tx_confirmed_ref = 0;
1031                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1032                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1034                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1035         return commitment_tx_confirmed_ref;
1036 }
1037 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1038         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1039         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1040                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1041                         uint64_t funding_txo_ref = 0;
1042                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1043                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1045                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1046         return funding_txo_ref;
1047 }
1048 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1049         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1050         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1051         return obj->update_completed.monitor_update_id;
1052 }
1053 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1054         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1055         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1056                         LDKOutPoint update_failed_var = obj->update_failed;
1057                         uint64_t update_failed_ref = 0;
1058                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1059                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1060                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1061                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1062         return update_failed_ref;
1063 }
1064 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
1065         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1066         switch(obj->tag) {
1067                 case LDKCOption_MonitorEventZ_Some: return 0;
1068                 case LDKCOption_MonitorEventZ_None: return 1;
1069                 default: abort();
1070         }
1071 }
1072 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
1073         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1074         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
1075                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1076         return some_ref;
1077 }
1078 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1079 CHECK(owner->result_ok);
1080         return COption_MonitorEventZ_clone(&*owner->contents.result);
1081 }
1082 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
1083         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1084         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
1085         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
1086         uint64_t ret_ref = (uint64_t)ret_copy;
1087         return ret_ref;
1088 }
1089
1090 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1091 CHECK(!owner->result_ok);
1092         return DecodeError_clone(&*owner->contents.err);
1093 }
1094 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
1095         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1096         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
1097         uint64_t ret_ref = 0;
1098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1101         ret_ref = (uint64_t)ret_var.inner;
1102         if (ret_var.is_owned) {
1103                 ret_ref |= 1;
1104         }
1105         return ret_ref;
1106 }
1107
1108 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1109 CHECK(owner->result_ok);
1110         return HTLCUpdate_clone(&*owner->contents.result);
1111 }
1112 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
1113         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1114         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
1115         uint64_t ret_ref = 0;
1116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1119         ret_ref = (uint64_t)ret_var.inner;
1120         if (ret_var.is_owned) {
1121                 ret_ref |= 1;
1122         }
1123         return ret_ref;
1124 }
1125
1126 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1127 CHECK(!owner->result_ok);
1128         return DecodeError_clone(&*owner->contents.err);
1129 }
1130 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
1131         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1132         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
1133         uint64_t ret_ref = 0;
1134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1137         ret_ref = (uint64_t)ret_var.inner;
1138         if (ret_var.is_owned) {
1139                 ret_ref |= 1;
1140         }
1141         return ret_ref;
1142 }
1143
1144 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1145 CHECK(owner->result_ok);
1146         return *owner->contents.result;
1147 }
1148 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
1149         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1150         CResult_NoneNoneZ_get_ok(owner_conv);
1151 }
1152
1153 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1154 CHECK(!owner->result_ok);
1155         return *owner->contents.err;
1156 }
1157 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
1158         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1159         CResult_NoneNoneZ_get_err(owner_conv);
1160 }
1161
1162 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1163         return OutPoint_clone(&owner->a);
1164 }
1165 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
1166         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1167         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
1168         uint64_t ret_ref = 0;
1169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1172         ret_ref = (uint64_t)ret_var.inner;
1173         if (ret_var.is_owned) {
1174                 ret_ref |= 1;
1175         }
1176         return ret_ref;
1177 }
1178
1179 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1180         return CVec_u8Z_clone(&owner->b);
1181 }
1182 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
1183         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1184         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
1185         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
1186         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1187         CVec_u8Z_free(ret_var);
1188         return ret_arr;
1189 }
1190
1191 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1192         return owner->a;
1193 }
1194 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
1195         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1196         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
1197         return ret_val;
1198 }
1199
1200 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1201         return CVec_u8Z_clone(&owner->b);
1202 }
1203 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
1204         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1205         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
1206         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
1207         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1208         CVec_u8Z_free(ret_var);
1209         return ret_arr;
1210 }
1211
1212 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1213         return ThirtyTwoBytes_clone(&owner->a);
1214 }
1215 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
1216         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1217         int8_tArray ret_arr = init_int8_tArray(32);
1218         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
1219         return ret_arr;
1220 }
1221
1222 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1223         return owner->b;
1224 }
1225 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
1226         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1227         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
1228         uint32_tArray ret_arr = NULL;
1229         ret_arr = init_uint32_tArray(ret_var.datalen);
1230         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1231         for (size_t v = 0; v < ret_var.datalen; v++) {
1232                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = &ret_var.data[v];
1233                 // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_u32ScriptZ
1234                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv) | 1;
1235         }
1236         
1237         return ret_arr;
1238 }
1239
1240 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1241         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1242         for (size_t i = 0; i < ret.datalen; i++) {
1243                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1244         }
1245         return ret;
1246 }
1247 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1248         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1249         switch(obj->tag) {
1250                 case LDKPaymentPurpose_InvoicePayment: return 0;
1251                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1252                 default: abort();
1253         }
1254 }
1255 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1256         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1257         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1258                         int8_tArray payment_preimage_arr = init_int8_tArray(32);
1259                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1260         return payment_preimage_arr;
1261 }
1262 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1263         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1264         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1265                         int8_tArray payment_secret_arr = init_int8_tArray(32);
1266                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1267         return payment_secret_arr;
1268 }
1269 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1270         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1271         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1272                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32);
1273                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1274         return spontaneous_payment_arr;
1275 }
1276 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1277         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1278         switch(obj->tag) {
1279                 case LDKCOption_u64Z_Some: return 0;
1280                 case LDKCOption_u64Z_None: return 1;
1281                 default: abort();
1282         }
1283 }
1284 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1285         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1286         assert(obj->tag == LDKCOption_u64Z_Some);
1287         return obj->some;
1288 }
1289 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1290         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1291         switch(obj->tag) {
1292                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1293                 case LDKNetworkUpdate_ChannelClosed: return 1;
1294                 case LDKNetworkUpdate_NodeFailure: return 2;
1295                 default: abort();
1296         }
1297 }
1298 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1299         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1300         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1301                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1302                         uint64_t msg_ref = 0;
1303                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1304                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1305                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1306                         msg_ref = (uint64_t)msg_var.inner & ~1;
1307         return msg_ref;
1308 }
1309 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1310         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1311         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1312         return obj->channel_closed.short_channel_id;
1313 }
1314 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1315         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1316         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1317         return obj->channel_closed.is_permanent;
1318 }
1319 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1320         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1321         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1322                         int8_tArray node_id_arr = init_int8_tArray(33);
1323                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1324         return node_id_arr;
1325 }
1326 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1327         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1328         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1329         return obj->node_failure.is_permanent;
1330 }
1331 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1332         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1333         switch(obj->tag) {
1334                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1335                 case LDKCOption_NetworkUpdateZ_None: return 1;
1336                 default: abort();
1337         }
1338 }
1339 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1340         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1341         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1342                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1343         return some_ref;
1344 }
1345 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1346         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1347         for (size_t i = 0; i < ret.datalen; i++) {
1348                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1349         }
1350         return ret;
1351 }
1352 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1353         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1354         switch(obj->tag) {
1355                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1356                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1357                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1358                 default: abort();
1359         }
1360 }
1361 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1362         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1363         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1364                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1365                         uint64_t outpoint_ref = 0;
1366                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1367                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1369                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1370         return outpoint_ref;
1371 }
1372 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1373         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1374         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1375                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1376         return (uint64_t)output_ref;
1377 }
1378 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1379         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1380         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1381                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1382                         uint64_t delayed_payment_output_ref = 0;
1383                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1384                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1385                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1386                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1387         return delayed_payment_output_ref;
1388 }
1389 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1390         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1391         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1392                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1393                         uint64_t static_payment_output_ref = 0;
1394                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1395                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1396                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1397                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1398         return static_payment_output_ref;
1399 }
1400 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1401         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1402         for (size_t i = 0; i < ret.datalen; i++) {
1403                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1404         }
1405         return ret;
1406 }
1407 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1408         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1409         switch(obj->tag) {
1410                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1411                 case LDKClosureReason_HolderForceClosed: return 1;
1412                 case LDKClosureReason_CooperativeClosure: return 2;
1413                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1414                 case LDKClosureReason_FundingTimedOut: return 4;
1415                 case LDKClosureReason_ProcessingError: return 5;
1416                 case LDKClosureReason_DisconnectedPeer: return 6;
1417                 case LDKClosureReason_OutdatedChannelManager: return 7;
1418                 default: abort();
1419         }
1420 }
1421 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1422         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1423         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1424                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1425                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1426         return peer_msg_conv;
1427 }
1428 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1429         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1430         assert(obj->tag == LDKClosureReason_ProcessingError);
1431                         LDKStr err_str = obj->processing_error.err;
1432                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1433         return err_conv;
1434 }
1435 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1436         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1437         switch(obj->tag) {
1438                 case LDKEvent_FundingGenerationReady: return 0;
1439                 case LDKEvent_PaymentReceived: return 1;
1440                 case LDKEvent_PaymentSent: return 2;
1441                 case LDKEvent_PaymentPathFailed: return 3;
1442                 case LDKEvent_PaymentFailed: return 4;
1443                 case LDKEvent_PendingHTLCsForwardable: return 5;
1444                 case LDKEvent_SpendableOutputs: return 6;
1445                 case LDKEvent_PaymentForwarded: return 7;
1446                 case LDKEvent_ChannelClosed: return 8;
1447                 case LDKEvent_DiscardFunding: return 9;
1448                 case LDKEvent_PaymentPathSuccessful: return 10;
1449                 default: abort();
1450         }
1451 }
1452 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1453         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1454         assert(obj->tag == LDKEvent_FundingGenerationReady);
1455                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32);
1456                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1457         return temporary_channel_id_arr;
1458 }
1459 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1460         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1461         assert(obj->tag == LDKEvent_FundingGenerationReady);
1462         return obj->funding_generation_ready.channel_value_satoshis;
1463 }
1464 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1465         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1466         assert(obj->tag == LDKEvent_FundingGenerationReady);
1467                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1468                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen);
1469                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1470         return output_script_arr;
1471 }
1472 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1473         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1474         assert(obj->tag == LDKEvent_FundingGenerationReady);
1475         return obj->funding_generation_ready.user_channel_id;
1476 }
1477 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1478         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1479         assert(obj->tag == LDKEvent_PaymentReceived);
1480                         int8_tArray payment_hash_arr = init_int8_tArray(32);
1481                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1482         return payment_hash_arr;
1483 }
1484 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1485         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1486         assert(obj->tag == LDKEvent_PaymentReceived);
1487         return obj->payment_received.amt;
1488 }
1489 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1490         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1491         assert(obj->tag == LDKEvent_PaymentReceived);
1492                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
1493         return purpose_ref;
1494 }
1495 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1496         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1497         assert(obj->tag == LDKEvent_PaymentSent);
1498                         int8_tArray payment_id_arr = init_int8_tArray(32);
1499                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1500         return payment_id_arr;
1501 }
1502 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1503         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1504         assert(obj->tag == LDKEvent_PaymentSent);
1505                         int8_tArray payment_preimage_arr = init_int8_tArray(32);
1506                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1507         return payment_preimage_arr;
1508 }
1509 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1510         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1511         assert(obj->tag == LDKEvent_PaymentSent);
1512                         int8_tArray payment_hash_arr = init_int8_tArray(32);
1513                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1514         return payment_hash_arr;
1515 }
1516 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1517         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1518         assert(obj->tag == LDKEvent_PaymentSent);
1519                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
1520         return fee_paid_msat_ref;
1521 }
1522 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1523         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1524         assert(obj->tag == LDKEvent_PaymentPathFailed);
1525                         int8_tArray payment_id_arr = init_int8_tArray(32);
1526                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1527         return payment_id_arr;
1528 }
1529 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1530         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1531         assert(obj->tag == LDKEvent_PaymentPathFailed);
1532                         int8_tArray payment_hash_arr = init_int8_tArray(32);
1533                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1534         return payment_hash_arr;
1535 }
1536 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1537         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1538         assert(obj->tag == LDKEvent_PaymentPathFailed);
1539         return obj->payment_path_failed.rejected_by_dest;
1540 }
1541 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1542         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1543         assert(obj->tag == LDKEvent_PaymentPathFailed);
1544                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
1545         return network_update_ref;
1546 }
1547 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1548         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1549         assert(obj->tag == LDKEvent_PaymentPathFailed);
1550         return obj->payment_path_failed.all_paths_failed;
1551 }
1552 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1553         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1554         assert(obj->tag == LDKEvent_PaymentPathFailed);
1555                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1556                         uint32_tArray path_arr = NULL;
1557                         path_arr = init_uint32_tArray(path_var.datalen);
1558                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1559                         for (size_t k = 0; k < path_var.datalen; k++) {
1560                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1561                                 uint64_t path_conv_10_ref = 0;
1562                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1563                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1564                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1565                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1566                                 path_arr_ptr[k] = path_conv_10_ref;
1567                         }
1568                         
1569         return path_arr;
1570 }
1571 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1572         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1573         assert(obj->tag == LDKEvent_PaymentPathFailed);
1574                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
1575         return short_channel_id_ref;
1576 }
1577 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1578         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1579         assert(obj->tag == LDKEvent_PaymentPathFailed);
1580                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1581                         uint64_t retry_ref = 0;
1582                         if ((uint64_t)retry_var.inner > 4096) {
1583                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1584                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1585                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1586                                 retry_ref = (uint64_t)retry_var.inner & ~1;
1587                         }
1588         return retry_ref;
1589 }
1590 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1591         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1592         assert(obj->tag == LDKEvent_PaymentFailed);
1593                         int8_tArray payment_id_arr = init_int8_tArray(32);
1594                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1595         return payment_id_arr;
1596 }
1597 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1598         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1599         assert(obj->tag == LDKEvent_PaymentFailed);
1600                         int8_tArray payment_hash_arr = init_int8_tArray(32);
1601                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1602         return payment_hash_arr;
1603 }
1604 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1605         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1606         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1607         return obj->pending_htl_cs_forwardable.time_forwardable;
1608 }
1609 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1610         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1611         assert(obj->tag == LDKEvent_SpendableOutputs);
1612                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1613                         uint32_tArray outputs_arr = NULL;
1614                         outputs_arr = init_uint32_tArray(outputs_var.datalen);
1615                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1616                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1617                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
1618                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1619                         }
1620                         
1621         return outputs_arr;
1622 }
1623 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1624         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1625         assert(obj->tag == LDKEvent_PaymentForwarded);
1626                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1627         return fee_earned_msat_ref;
1628 }
1629 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1630         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1631         assert(obj->tag == LDKEvent_PaymentForwarded);
1632         return obj->payment_forwarded.claim_from_onchain_tx;
1633 }
1634 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1635         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1636         assert(obj->tag == LDKEvent_ChannelClosed);
1637                         int8_tArray channel_id_arr = init_int8_tArray(32);
1638                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1639         return channel_id_arr;
1640 }
1641 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1642         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1643         assert(obj->tag == LDKEvent_ChannelClosed);
1644         return obj->channel_closed.user_channel_id;
1645 }
1646 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1647         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1648         assert(obj->tag == LDKEvent_ChannelClosed);
1649                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
1650         return reason_ref;
1651 }
1652 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_DiscardFunding);
1655                         int8_tArray channel_id_arr = init_int8_tArray(32);
1656                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1657         return channel_id_arr;
1658 }
1659 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_DiscardFunding);
1662                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1663                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen);
1664                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1665         return transaction_arr;
1666 }
1667 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1668         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1669         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1670                         int8_tArray payment_id_arr = init_int8_tArray(32);
1671                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1672         return payment_id_arr;
1673 }
1674 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1675         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1676         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1677                         int8_tArray payment_hash_arr = init_int8_tArray(32);
1678                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1679         return payment_hash_arr;
1680 }
1681 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1682         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1683         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1684                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1685                         uint32_tArray path_arr = NULL;
1686                         path_arr = init_uint32_tArray(path_var.datalen);
1687                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1688                         for (size_t k = 0; k < path_var.datalen; k++) {
1689                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1690                                 uint64_t path_conv_10_ref = 0;
1691                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1692                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1693                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1694                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1695                                 path_arr_ptr[k] = path_conv_10_ref;
1696                         }
1697                         
1698         return path_arr;
1699 }
1700 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1701         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1702         for (size_t i = 0; i < ret.datalen; i++) {
1703                 ret.data[i] = Event_clone(&orig->data[i]);
1704         }
1705         return ret;
1706 }
1707 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1708         return owner->a;
1709 }
1710 int64_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1711         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1712         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1713         return ret_val;
1714 }
1715
1716 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1717         return owner->b;
1718 }
1719 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1720         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1721         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1722         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
1723         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1724         return ret_arr;
1725 }
1726
1727 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1728         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1729         for (size_t i = 0; i < ret.datalen; i++) {
1730                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1731         }
1732         return ret;
1733 }
1734 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1735         return owner->a;
1736 }
1737 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
1738         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1739         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
1740         return ret_val;
1741 }
1742
1743 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1744         return TxOut_clone(&owner->b);
1745 }
1746 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
1747         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1748         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1749         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
1750         return (uint64_t)ret_ref;
1751 }
1752
1753 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1754         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1755         for (size_t i = 0; i < ret.datalen; i++) {
1756                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1757         }
1758         return ret;
1759 }
1760 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1761         return ThirtyTwoBytes_clone(&owner->a);
1762 }
1763 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
1764         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1765         int8_tArray ret_arr = init_int8_tArray(32);
1766         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
1767         return ret_arr;
1768 }
1769
1770 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1771         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
1772 }
1773 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
1774         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1775         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
1776         uint32_tArray ret_arr = NULL;
1777         ret_arr = init_uint32_tArray(ret_var.datalen);
1778         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1779         for (size_t u = 0; u < ret_var.datalen; u++) {
1780                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1781                 *ret_conv_20_conv = ret_var.data[u];
1782                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
1783         }
1784         
1785         FREE(ret_var.data);
1786         return ret_arr;
1787 }
1788
1789 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
1790         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 };
1791         for (size_t i = 0; i < ret.datalen; i++) {
1792                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
1793         }
1794         return ret;
1795 }
1796 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1797         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1798         for (size_t i = 0; i < ret.datalen; i++) {
1799                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1800         }
1801         return ret;
1802 }
1803 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
1804         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1805         switch(obj->tag) {
1806                 case LDKBalance_ClaimableOnChannelClose: return 0;
1807                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
1808                 case LDKBalance_ContentiousClaimable: return 2;
1809                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
1810                 default: abort();
1811         }
1812 }
1813 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
1814         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1815         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
1816         return obj->claimable_on_channel_close.claimable_amount_satoshis;
1817 }
1818 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
1819         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1820         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1821         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
1822 }
1823 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
1824         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1825         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1826         return obj->claimable_awaiting_confirmations.confirmation_height;
1827 }
1828 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
1829         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1830         assert(obj->tag == LDKBalance_ContentiousClaimable);
1831         return obj->contentious_claimable.claimable_amount_satoshis;
1832 }
1833 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
1834         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1835         assert(obj->tag == LDKBalance_ContentiousClaimable);
1836         return obj->contentious_claimable.timeout_height;
1837 }
1838 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
1839         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1840         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1841         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
1842 }
1843 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
1844         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1845         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1846         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
1847 }
1848 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
1849         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
1850         for (size_t i = 0; i < ret.datalen; i++) {
1851                 ret.data[i] = Balance_clone(&orig->data[i]);
1852         }
1853         return ret;
1854 }
1855 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1856         return owner->a;
1857 }
1858 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
1859         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1860         int8_tArray ret_arr = init_int8_tArray(64);
1861         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
1862         return ret_arr;
1863 }
1864
1865 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1866         return owner->b;
1867 }
1868 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
1869         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1870         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
1871         ptrArray ret_arr = NULL;
1872         ret_arr = init_ptrArray(ret_var.datalen);
1873         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
1874         for (size_t m = 0; m < ret_var.datalen; m++) {
1875                 int8_tArray ret_conv_12_arr = init_int8_tArray(64);
1876                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
1877                 ret_arr_ptr[m] = ret_conv_12_arr;
1878         }
1879         
1880         return ret_arr;
1881 }
1882
1883 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1884 CHECK(owner->result_ok);
1885         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
1886 }
1887 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
1888         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1889         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1890         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
1891         return ((uint64_t)ret_conv);
1892 }
1893
1894 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1895 CHECK(!owner->result_ok);
1896         return *owner->contents.err;
1897 }
1898 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
1899         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1900         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
1901 }
1902
1903 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1904 CHECK(owner->result_ok);
1905         return *owner->contents.result;
1906 }
1907 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
1908         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1909         int8_tArray ret_arr = init_int8_tArray(64);
1910         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1911         return ret_arr;
1912 }
1913
1914 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1915 CHECK(!owner->result_ok);
1916         return *owner->contents.err;
1917 }
1918 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
1919         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1920         CResult_SignatureNoneZ_get_err(owner_conv);
1921 }
1922
1923 typedef struct LDKBaseSign_JCalls {
1924         atomic_size_t refcnt;
1925         uint32_t instance_ptr;
1926 } LDKBaseSign_JCalls;
1927 static void LDKBaseSign_JCalls_free(void* this_arg) {
1928         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1929         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1930                 FREE(j_calls);
1931         }
1932 }
1933 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1934         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1935         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 3, (uint32_t)idx);
1936         LDKPublicKey ret_ref;
1937         CHECK(ret->arr_len == 33);
1938         memcpy(ret_ref.compressed_form, ret->elems, 33);
1939         return ret_ref;
1940 }
1941 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1942         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1943         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 4, (uint32_t)idx);
1944         LDKThirtyTwoBytes ret_ref;
1945         CHECK(ret->arr_len == 32);
1946         memcpy(ret_ref.data, ret->elems, 32);
1947         return ret_ref;
1948 }
1949 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1950         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1951         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1952         uint64_t holder_tx_ref = 0;
1953         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1954         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1955         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1956         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1957         holder_tx_ref = (uint64_t)holder_tx_var.inner;
1958         if (holder_tx_var.is_owned) {
1959                 holder_tx_ref |= 1;
1960         }
1961         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 5, (uint32_t)holder_tx_ref);
1962         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1963         CHECK_ACCESS(ret_ptr);
1964         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1965         FREE((void*)ret);
1966         return ret_conv;
1967 }
1968 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1969         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1970         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 6);
1971         LDKThirtyTwoBytes ret_ref;
1972         CHECK(ret->arr_len == 32);
1973         memcpy(ret_ref.data, ret->elems, 32);
1974         return ret_ref;
1975 }
1976 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1977         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1978         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1979         uint64_t commitment_tx_ref = 0;
1980         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1981         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1982         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1983         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1984         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1985         if (commitment_tx_var.is_owned) {
1986                 commitment_tx_ref |= 1;
1987         }
1988         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 7, (uint32_t)commitment_tx_ref);
1989         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1990         CHECK_ACCESS(ret_ptr);
1991         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1992         FREE((void*)ret);
1993         return ret_conv;
1994 }
1995 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1996         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1997         int8_tArray secret_arr = init_int8_tArray(32);
1998         memcpy(secret_arr->elems, *secret, 32);
1999         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 8, (uint32_t)idx, (uint32_t)secret_arr);
2000         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2001         CHECK_ACCESS(ret_ptr);
2002         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2003         FREE((void*)ret);
2004         return ret_conv;
2005 }
2006 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2007         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2008         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2009         uint64_t commitment_tx_ref = 0;
2010         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2011         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2012         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2013         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2014         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2015         if (commitment_tx_var.is_owned) {
2016                 commitment_tx_ref |= 1;
2017         }
2018         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 9, (uint32_t)commitment_tx_ref);
2019         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2020         CHECK_ACCESS(ret_ptr);
2021         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2022         FREE((void*)ret);
2023         return ret_conv;
2024 }
2025 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]) {
2026         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2027         LDKTransaction justice_tx_var = justice_tx;
2028         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen);
2029         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2030         Transaction_free(justice_tx_var);
2031         int8_tArray per_commitment_key_arr = init_int8_tArray(32);
2032         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2033         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);
2034         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2035         CHECK_ACCESS(ret_ptr);
2036         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2037         FREE((void*)ret);
2038         return ret_conv;
2039 }
2040 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) {
2041         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2042         LDKTransaction justice_tx_var = justice_tx;
2043         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen);
2044         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2045         Transaction_free(justice_tx_var);
2046         int8_tArray per_commitment_key_arr = init_int8_tArray(32);
2047         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2048         LDKHTLCOutputInCommitment htlc_var = *htlc;
2049         uint64_t htlc_ref = 0;
2050         htlc_var = HTLCOutputInCommitment_clone(htlc);
2051         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2052         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2053         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2054         htlc_ref = (uint64_t)htlc_var.inner;
2055         if (htlc_var.is_owned) {
2056                 htlc_ref |= 1;
2057         }
2058         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);
2059         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2060         CHECK_ACCESS(ret_ptr);
2061         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2062         FREE((void*)ret);
2063         return ret_conv;
2064 }
2065 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) {
2066         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2067         LDKTransaction htlc_tx_var = htlc_tx;
2068         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen);
2069         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
2070         Transaction_free(htlc_tx_var);
2071         int8_tArray per_commitment_point_arr = init_int8_tArray(33);
2072         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
2073         LDKHTLCOutputInCommitment htlc_var = *htlc;
2074         uint64_t htlc_ref = 0;
2075         htlc_var = HTLCOutputInCommitment_clone(htlc);
2076         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2077         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2078         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2079         htlc_ref = (uint64_t)htlc_var.inner;
2080         if (htlc_var.is_owned) {
2081                 htlc_ref |= 1;
2082         }
2083         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);
2084         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2085         CHECK_ACCESS(ret_ptr);
2086         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2087         FREE((void*)ret);
2088         return ret_conv;
2089 }
2090 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2091         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2092         LDKClosingTransaction closing_tx_var = *closing_tx;
2093         uint64_t closing_tx_ref = 0;
2094         closing_tx_var = ClosingTransaction_clone(closing_tx);
2095         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2096         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2097         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2098         closing_tx_ref = (uint64_t)closing_tx_var.inner;
2099         if (closing_tx_var.is_owned) {
2100                 closing_tx_ref |= 1;
2101         }
2102         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 13, (uint32_t)closing_tx_ref);
2103         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2104         CHECK_ACCESS(ret_ptr);
2105         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2106         FREE((void*)ret);
2107         return ret_conv;
2108 }
2109 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2110         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2111         LDKUnsignedChannelAnnouncement msg_var = *msg;
2112         uint64_t msg_ref = 0;
2113         msg_var = UnsignedChannelAnnouncement_clone(msg);
2114         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2115         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2116         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2117         msg_ref = (uint64_t)msg_var.inner;
2118         if (msg_var.is_owned) {
2119                 msg_ref |= 1;
2120         }
2121         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 14, (uint32_t)msg_ref);
2122         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2123         CHECK_ACCESS(ret_ptr);
2124         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2125         FREE((void*)ret);
2126         return ret_conv;
2127 }
2128 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2129         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2130         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2131         uint64_t channel_parameters_ref = 0;
2132         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2133         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2134         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2135         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
2136         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2137         if (channel_parameters_var.is_owned) {
2138                 channel_parameters_ref |= 1;
2139         }
2140         js_invoke_function_1(j_calls->instance_ptr, 15, (uint32_t)channel_parameters_ref);
2141 }
2142 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2143         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2144         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2145 }
2146 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
2147         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2148         atomic_init(&calls->refcnt, 1);
2149         calls->instance_ptr = o;
2150
2151         LDKChannelPublicKeys pubkeys_conv;
2152         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2153         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2154         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2155
2156         LDKBaseSign ret = {
2157                 .this_arg = (void*) calls,
2158                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2159                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2160                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2161                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2162                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2163                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2164                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2165                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2166                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2167                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2168                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2169                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2170                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2171                 .free = LDKBaseSign_JCalls_free,
2172                 .pubkeys = pubkeys_conv,
2173                 .set_pubkeys = NULL,
2174         };
2175         return ret;
2176 }
2177 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
2178         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2179         *res_ptr = LDKBaseSign_init(o, pubkeys);
2180         return (long)res_ptr;
2181 }
2182 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2183         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2185         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2186         int8_tArray ret_arr = init_int8_tArray(33);
2187         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2188         return ret_arr;
2189 }
2190
2191 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2192         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2193         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2194         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2195         int8_tArray ret_arr = init_int8_tArray(32);
2196         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2197         return ret_arr;
2198 }
2199
2200 uint32_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2201         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2202         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2203         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2204         LDKHolderCommitmentTransaction holder_tx_conv;
2205         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2206         holder_tx_conv.is_owned = false;
2207         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
2208         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2209         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2210         return (uint64_t)ret_conv;
2211 }
2212
2213 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2214         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2216         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2217         int8_tArray ret_arr = init_int8_tArray(32);
2218         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2219         return ret_arr;
2220 }
2221
2222 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2223         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2224         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2225         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2226         LDKCommitmentTransaction commitment_tx_conv;
2227         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2228         commitment_tx_conv.is_owned = false;
2229         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2230         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2231         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2232         return (uint64_t)ret_conv;
2233 }
2234
2235 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) {
2236         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2237         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2238         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2239         unsigned char secret_arr[32];
2240         CHECK(secret->arr_len == 32);
2241         memcpy(secret_arr, secret->elems, 32);
2242         unsigned char (*secret_ref)[32] = &secret_arr;
2243         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2244         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2245         return (uint64_t)ret_conv;
2246 }
2247
2248 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) {
2249         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2251         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2252         LDKHolderCommitmentTransaction commitment_tx_conv;
2253         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2254         commitment_tx_conv.is_owned = false;
2255         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2256         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2257         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2258         return (uint64_t)ret_conv;
2259 }
2260
2261 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, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
2262         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2265         LDKTransaction justice_tx_ref;
2266         justice_tx_ref.datalen = justice_tx->arr_len;
2267         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2268         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen);
2269         justice_tx_ref.data_is_owned = true;
2270         unsigned char per_commitment_key_arr[32];
2271         CHECK(per_commitment_key->arr_len == 32);
2272         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32);
2273         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2274         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2275         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2276         return (uint64_t)ret_conv;
2277 }
2278
2279 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, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
2280         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2281         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2282         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2283         LDKTransaction justice_tx_ref;
2284         justice_tx_ref.datalen = justice_tx->arr_len;
2285         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2286         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen);
2287         justice_tx_ref.data_is_owned = true;
2288         unsigned char per_commitment_key_arr[32];
2289         CHECK(per_commitment_key->arr_len == 32);
2290         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32);
2291         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2292         LDKHTLCOutputInCommitment htlc_conv;
2293         htlc_conv.inner = (void*)(htlc & (~1));
2294         htlc_conv.is_owned = false;
2295         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2296         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2297         *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);
2298         return (uint64_t)ret_conv;
2299 }
2300
2301 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, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
2302         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2303         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2304         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2305         LDKTransaction htlc_tx_ref;
2306         htlc_tx_ref.datalen = htlc_tx->arr_len;
2307         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2308         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen);
2309         htlc_tx_ref.data_is_owned = true;
2310         LDKPublicKey per_commitment_point_ref;
2311         CHECK(per_commitment_point->arr_len == 33);
2312         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
2313         LDKHTLCOutputInCommitment htlc_conv;
2314         htlc_conv.inner = (void*)(htlc & (~1));
2315         htlc_conv.is_owned = false;
2316         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2317         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2318         *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);
2319         return (uint64_t)ret_conv;
2320 }
2321
2322 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2323         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2324         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2325         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2326         LDKClosingTransaction closing_tx_conv;
2327         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2328         closing_tx_conv.is_owned = false;
2329         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2330         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2331         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2332         return (uint64_t)ret_conv;
2333 }
2334
2335 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2336         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2337         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2338         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2339         LDKUnsignedChannelAnnouncement msg_conv;
2340         msg_conv.inner = (void*)(msg & (~1));
2341         msg_conv.is_owned = false;
2342         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2343         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2344         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2345         return (uint64_t)ret_conv;
2346 }
2347
2348 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2349         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2350         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2351         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2352         LDKChannelTransactionParameters channel_parameters_conv;
2353         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2354         channel_parameters_conv.is_owned = false;
2355         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
2356         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2357 }
2358
2359 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2360         if (this_arg->set_pubkeys != NULL)
2361                 this_arg->set_pubkeys(this_arg);
2362         return this_arg->pubkeys;
2363 }
2364 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2365         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2366         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2367         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2368         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2369         uint64_t ret_ref = 0;
2370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2373         ret_ref = (uint64_t)ret_var.inner;
2374         if (ret_var.is_owned) {
2375                 ret_ref |= 1;
2376         }
2377         return ret_ref;
2378 }
2379
2380 typedef struct LDKSign_JCalls {
2381         atomic_size_t refcnt;
2382         uint32_t instance_ptr;
2383         LDKBaseSign_JCalls* BaseSign;
2384 } LDKSign_JCalls;
2385 static void LDKSign_JCalls_free(void* this_arg) {
2386         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2387         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2388                 FREE(j_calls);
2389         }
2390 }
2391 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2392         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2393         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
2394         LDKCVec_u8Z ret_ref;
2395         ret_ref.datalen = ret->arr_len;
2396         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2397         memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
2398         return ret_ref;
2399 }
2400 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2401         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2402         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2403         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2404 }
2405 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2406         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2407         atomic_init(&calls->refcnt, 1);
2408         calls->instance_ptr = o;
2409
2410         LDKChannelPublicKeys pubkeys_conv;
2411         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2412         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2413         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2414
2415         LDKSign ret = {
2416                 .this_arg = (void*) calls,
2417                 .write = write_LDKSign_jcall,
2418                 .cloned = LDKSign_JCalls_cloned,
2419                 .free = LDKSign_JCalls_free,
2420                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2421         };
2422         calls->BaseSign = ret.BaseSign.this_arg;
2423         return ret;
2424 }
2425 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2426         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2427         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2428         return (long)res_ptr;
2429 }
2430 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
2431         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2432         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2433         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2434         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2435         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
2436         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2437         CVec_u8Z_free(ret_var);
2438         return ret_arr;
2439 }
2440
2441 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2442         return ThirtyTwoBytes_clone(&owner->a);
2443 }
2444 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
2445         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2446         int8_tArray ret_arr = init_int8_tArray(32);
2447         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
2448         return ret_arr;
2449 }
2450
2451 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2452         return ChannelMonitor_clone(&owner->b);
2453 }
2454 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
2455         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2456         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
2457         uint64_t ret_ref = 0;
2458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2461         ret_ref = (uint64_t)ret_var.inner;
2462         if (ret_var.is_owned) {
2463                 ret_ref |= 1;
2464         }
2465         return ret_ref;
2466 }
2467
2468 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2469 CHECK(owner->result_ok);
2470         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
2471 }
2472 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
2473         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2474         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2475         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
2476         return ((uint64_t)ret_conv);
2477 }
2478
2479 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2480 CHECK(!owner->result_ok);
2481         return DecodeError_clone(&*owner->contents.err);
2482 }
2483 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
2484         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2485         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
2486         uint64_t ret_ref = 0;
2487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2490         ret_ref = (uint64_t)ret_var.inner;
2491         if (ret_var.is_owned) {
2492                 ret_ref |= 1;
2493         }
2494         return ret_ref;
2495 }
2496
2497 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2498 CHECK(owner->result_ok);
2499         return RouteHop_clone(&*owner->contents.result);
2500 }
2501 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
2502         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2503         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2504         uint64_t ret_ref = 0;
2505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2508         ret_ref = (uint64_t)ret_var.inner;
2509         if (ret_var.is_owned) {
2510                 ret_ref |= 1;
2511         }
2512         return ret_ref;
2513 }
2514
2515 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2516 CHECK(!owner->result_ok);
2517         return DecodeError_clone(&*owner->contents.err);
2518 }
2519 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
2520         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2521         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2522         uint64_t ret_ref = 0;
2523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2526         ret_ref = (uint64_t)ret_var.inner;
2527         if (ret_var.is_owned) {
2528                 ret_ref |= 1;
2529         }
2530         return ret_ref;
2531 }
2532
2533 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2534         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2535         for (size_t i = 0; i < ret.datalen; i++) {
2536                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2537         }
2538         return ret;
2539 }
2540 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2541 CHECK(owner->result_ok);
2542         return Route_clone(&*owner->contents.result);
2543 }
2544 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
2545         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2546         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2547         uint64_t ret_ref = 0;
2548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2551         ret_ref = (uint64_t)ret_var.inner;
2552         if (ret_var.is_owned) {
2553                 ret_ref |= 1;
2554         }
2555         return ret_ref;
2556 }
2557
2558 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2559 CHECK(!owner->result_ok);
2560         return DecodeError_clone(&*owner->contents.err);
2561 }
2562 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
2563         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2564         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2565         uint64_t ret_ref = 0;
2566         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2567         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2569         ret_ref = (uint64_t)ret_var.inner;
2570         if (ret_var.is_owned) {
2571                 ret_ref |= 1;
2572         }
2573         return ret_ref;
2574 }
2575
2576 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2577 CHECK(owner->result_ok);
2578         return RouteParameters_clone(&*owner->contents.result);
2579 }
2580 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
2581         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2582         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2583         uint64_t ret_ref = 0;
2584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2587         ret_ref = (uint64_t)ret_var.inner;
2588         if (ret_var.is_owned) {
2589                 ret_ref |= 1;
2590         }
2591         return ret_ref;
2592 }
2593
2594 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2595 CHECK(!owner->result_ok);
2596         return DecodeError_clone(&*owner->contents.err);
2597 }
2598 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
2599         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2600         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2601         uint64_t ret_ref = 0;
2602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2605         ret_ref = (uint64_t)ret_var.inner;
2606         if (ret_var.is_owned) {
2607                 ret_ref |= 1;
2608         }
2609         return ret_ref;
2610 }
2611
2612 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2613         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2614         for (size_t i = 0; i < ret.datalen; i++) {
2615                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2616         }
2617         return ret;
2618 }
2619 static inline struct LDKPayee CResult_PayeeDecodeErrorZ_get_ok(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2620 CHECK(owner->result_ok);
2621         return Payee_clone(&*owner->contents.result);
2622 }
2623 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_ok"))) TS_CResult_PayeeDecodeErrorZ_get_ok(uint32_t owner) {
2624         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2625         LDKPayee ret_var = CResult_PayeeDecodeErrorZ_get_ok(owner_conv);
2626         uint64_t ret_ref = 0;
2627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2630         ret_ref = (uint64_t)ret_var.inner;
2631         if (ret_var.is_owned) {
2632                 ret_ref |= 1;
2633         }
2634         return ret_ref;
2635 }
2636
2637 static inline struct LDKDecodeError CResult_PayeeDecodeErrorZ_get_err(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2638 CHECK(!owner->result_ok);
2639         return DecodeError_clone(&*owner->contents.err);
2640 }
2641 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_err"))) TS_CResult_PayeeDecodeErrorZ_get_err(uint32_t owner) {
2642         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2643         LDKDecodeError ret_var = CResult_PayeeDecodeErrorZ_get_err(owner_conv);
2644         uint64_t ret_ref = 0;
2645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2648         ret_ref = (uint64_t)ret_var.inner;
2649         if (ret_var.is_owned) {
2650                 ret_ref |= 1;
2651         }
2652         return ret_ref;
2653 }
2654
2655 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2656         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2657         for (size_t i = 0; i < ret.datalen; i++) {
2658                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2659         }
2660         return ret;
2661 }
2662 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2663 CHECK(owner->result_ok);
2664         return RouteHint_clone(&*owner->contents.result);
2665 }
2666 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
2667         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2668         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2669         uint64_t ret_ref = 0;
2670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2673         ret_ref = (uint64_t)ret_var.inner;
2674         if (ret_var.is_owned) {
2675                 ret_ref |= 1;
2676         }
2677         return ret_ref;
2678 }
2679
2680 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2681 CHECK(!owner->result_ok);
2682         return DecodeError_clone(&*owner->contents.err);
2683 }
2684 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
2685         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2686         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2687         uint64_t ret_ref = 0;
2688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2691         ret_ref = (uint64_t)ret_var.inner;
2692         if (ret_var.is_owned) {
2693                 ret_ref |= 1;
2694         }
2695         return ret_ref;
2696 }
2697
2698 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2699 CHECK(owner->result_ok);
2700         return RouteHintHop_clone(&*owner->contents.result);
2701 }
2702 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
2703         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2704         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2705         uint64_t ret_ref = 0;
2706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2709         ret_ref = (uint64_t)ret_var.inner;
2710         if (ret_var.is_owned) {
2711                 ret_ref |= 1;
2712         }
2713         return ret_ref;
2714 }
2715
2716 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2717 CHECK(!owner->result_ok);
2718         return DecodeError_clone(&*owner->contents.err);
2719 }
2720 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
2721         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2722         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2723         uint64_t ret_ref = 0;
2724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2727         ret_ref = (uint64_t)ret_var.inner;
2728         if (ret_var.is_owned) {
2729                 ret_ref |= 1;
2730         }
2731         return ret_ref;
2732 }
2733
2734 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2735         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2736         for (size_t i = 0; i < ret.datalen; i++) {
2737                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2738         }
2739         return ret;
2740 }
2741 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2742 CHECK(owner->result_ok);
2743         return Route_clone(&*owner->contents.result);
2744 }
2745 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
2746         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2747         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2748         uint64_t ret_ref = 0;
2749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2752         ret_ref = (uint64_t)ret_var.inner;
2753         if (ret_var.is_owned) {
2754                 ret_ref |= 1;
2755         }
2756         return ret_ref;
2757 }
2758
2759 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2760 CHECK(!owner->result_ok);
2761         return LightningError_clone(&*owner->contents.err);
2762 }
2763 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
2764         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2765         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2766         uint64_t ret_ref = 0;
2767         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2768         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2770         ret_ref = (uint64_t)ret_var.inner;
2771         if (ret_var.is_owned) {
2772                 ret_ref |= 1;
2773         }
2774         return ret_ref;
2775 }
2776
2777 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2778 CHECK(owner->result_ok);
2779         return *owner->contents.result;
2780 }
2781 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
2782         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2783         CResult_NoneLightningErrorZ_get_ok(owner_conv);
2784 }
2785
2786 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2787 CHECK(!owner->result_ok);
2788         return LightningError_clone(&*owner->contents.err);
2789 }
2790 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
2791         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2792         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
2793         uint64_t ret_ref = 0;
2794         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2795         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2797         ret_ref = (uint64_t)ret_var.inner;
2798         if (ret_var.is_owned) {
2799                 ret_ref |= 1;
2800         }
2801         return ret_ref;
2802 }
2803
2804 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2805         return owner->a;
2806 }
2807 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
2808         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2809         int8_tArray ret_arr = init_int8_tArray(33);
2810         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
2811         return ret_arr;
2812 }
2813
2814 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2815         return Type_clone(&owner->b);
2816 }
2817 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
2818         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2819         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
2820         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
2821         return (uint64_t)ret_ret;
2822 }
2823
2824 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
2825         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
2826         for (size_t i = 0; i < ret.datalen; i++) {
2827                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
2828         }
2829         return ret;
2830 }
2831 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2832         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2833         switch(obj->tag) {
2834                 case LDKErrorAction_DisconnectPeer: return 0;
2835                 case LDKErrorAction_IgnoreError: return 1;
2836                 case LDKErrorAction_IgnoreAndLog: return 2;
2837                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2838                 case LDKErrorAction_SendErrorMessage: return 4;
2839                 default: abort();
2840         }
2841 }
2842 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2843         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2844         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2845                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2846                         uint64_t msg_ref = 0;
2847                         if ((uint64_t)msg_var.inner > 4096) {
2848                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2849                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2850                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2851                                 msg_ref = (uint64_t)msg_var.inner & ~1;
2852                         }
2853         return msg_ref;
2854 }
2855 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2856         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2857         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2858                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2859         return ignore_and_log_conv;
2860 }
2861 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2862         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2863         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2864                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2865                         uint64_t msg_ref = 0;
2866                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2869                         msg_ref = (uint64_t)msg_var.inner & ~1;
2870         return msg_ref;
2871 }
2872 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2873         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2874         switch(obj->tag) {
2875                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2876                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2877                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2878                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2879                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2880                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2881                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2882                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2883                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2884                 case LDKMessageSendEvent_SendShutdown: return 9;
2885                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2886                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2887                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2888                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2889                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2890                 case LDKMessageSendEvent_HandleError: return 15;
2891                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2892                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2893                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2894                 default: abort();
2895         }
2896 }
2897 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2898         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2899         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2900                         int8_tArray node_id_arr = init_int8_tArray(33);
2901                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2902         return node_id_arr;
2903 }
2904 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2905         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2906         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2907                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2908                         uint64_t msg_ref = 0;
2909                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2910                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2911                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2912                         msg_ref = (uint64_t)msg_var.inner & ~1;
2913         return msg_ref;
2914 }
2915 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2916         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2917         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2918                         int8_tArray node_id_arr = init_int8_tArray(33);
2919                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2920         return node_id_arr;
2921 }
2922 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2923         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2924         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2925                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2926                         uint64_t msg_ref = 0;
2927                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2930                         msg_ref = (uint64_t)msg_var.inner & ~1;
2931         return msg_ref;
2932 }
2933 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2934         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2935         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2936                         int8_tArray node_id_arr = init_int8_tArray(33);
2937                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2938         return node_id_arr;
2939 }
2940 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2941         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2942         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2943                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2944                         uint64_t msg_ref = 0;
2945                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2946                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2947                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2948                         msg_ref = (uint64_t)msg_var.inner & ~1;
2949         return msg_ref;
2950 }
2951 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2952         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2953         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2954                         int8_tArray node_id_arr = init_int8_tArray(33);
2955                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2956         return node_id_arr;
2957 }
2958 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2959         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2960         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2961                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2962                         uint64_t msg_ref = 0;
2963                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2964                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2965                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2966                         msg_ref = (uint64_t)msg_var.inner & ~1;
2967         return msg_ref;
2968 }
2969 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2970         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2971         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2972                         int8_tArray node_id_arr = init_int8_tArray(33);
2973                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2974         return node_id_arr;
2975 }
2976 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2977         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2978         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2979                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2980                         uint64_t msg_ref = 0;
2981                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2982                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2983                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2984                         msg_ref = (uint64_t)msg_var.inner & ~1;
2985         return msg_ref;
2986 }
2987 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2988         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2989         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2990                         int8_tArray node_id_arr = init_int8_tArray(33);
2991                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2992         return node_id_arr;
2993 }
2994 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2995         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2996         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2997                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2998                         uint64_t msg_ref = 0;
2999                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3000                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3001                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3002                         msg_ref = (uint64_t)msg_var.inner & ~1;
3003         return msg_ref;
3004 }
3005 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
3006         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3007         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3008                         int8_tArray node_id_arr = init_int8_tArray(33);
3009                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
3010         return node_id_arr;
3011 }
3012 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
3013         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3014         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3015                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3016                         uint64_t updates_ref = 0;
3017                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3018                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3019                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3020                         updates_ref = (uint64_t)updates_var.inner & ~1;
3021         return updates_ref;
3022 }
3023 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
3024         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3025         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3026                         int8_tArray node_id_arr = init_int8_tArray(33);
3027                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
3028         return node_id_arr;
3029 }
3030 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
3031         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3032         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3033                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3034                         uint64_t msg_ref = 0;
3035                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3036                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3037                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3038                         msg_ref = (uint64_t)msg_var.inner & ~1;
3039         return msg_ref;
3040 }
3041 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
3042         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3043         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3044                         int8_tArray node_id_arr = init_int8_tArray(33);
3045                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
3046         return node_id_arr;
3047 }
3048 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
3049         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3050         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3051                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3052                         uint64_t msg_ref = 0;
3053                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3054                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3056                         msg_ref = (uint64_t)msg_var.inner & ~1;
3057         return msg_ref;
3058 }
3059 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
3060         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3061         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3062                         int8_tArray node_id_arr = init_int8_tArray(33);
3063                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
3064         return node_id_arr;
3065 }
3066 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
3067         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3068         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3069                         LDKShutdown msg_var = obj->send_shutdown.msg;
3070                         uint64_t msg_ref = 0;
3071                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3072                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3073                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3074                         msg_ref = (uint64_t)msg_var.inner & ~1;
3075         return msg_ref;
3076 }
3077 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
3078         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3079         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3080                         int8_tArray node_id_arr = init_int8_tArray(33);
3081                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
3082         return node_id_arr;
3083 }
3084 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
3085         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3086         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3087                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3088                         uint64_t msg_ref = 0;
3089                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3090                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3091                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3092                         msg_ref = (uint64_t)msg_var.inner & ~1;
3093         return msg_ref;
3094 }
3095 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
3096         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3097         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3098                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3099                         uint64_t msg_ref = 0;
3100                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3101                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3102                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3103                         msg_ref = (uint64_t)msg_var.inner & ~1;
3104         return msg_ref;
3105 }
3106 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
3107         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3108         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3109                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3110                         uint64_t update_msg_ref = 0;
3111                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3114                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
3115         return update_msg_ref;
3116 }
3117 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
3118         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3119         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
3120                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3121                         uint64_t msg_ref = 0;
3122                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3125                         msg_ref = (uint64_t)msg_var.inner & ~1;
3126         return msg_ref;
3127 }
3128 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
3129         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3130         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
3131                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3132                         uint64_t msg_ref = 0;
3133                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3134                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3135                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3136                         msg_ref = (uint64_t)msg_var.inner & ~1;
3137         return msg_ref;
3138 }
3139 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
3140         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3141         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3142                         int8_tArray node_id_arr = init_int8_tArray(33);
3143                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
3144         return node_id_arr;
3145 }
3146 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
3147         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3148         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3149                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3150                         uint64_t msg_ref = 0;
3151                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3152                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3153                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3154                         msg_ref = (uint64_t)msg_var.inner & ~1;
3155         return msg_ref;
3156 }
3157 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
3158         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3159         assert(obj->tag == LDKMessageSendEvent_HandleError);
3160                         int8_tArray node_id_arr = init_int8_tArray(33);
3161                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
3162         return node_id_arr;
3163 }
3164 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
3165         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3166         assert(obj->tag == LDKMessageSendEvent_HandleError);
3167                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
3168         return action_ref;
3169 }
3170 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
3171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3172         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3173                         int8_tArray node_id_arr = init_int8_tArray(33);
3174                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
3175         return node_id_arr;
3176 }
3177 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
3178         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3179         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3180                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3181                         uint64_t msg_ref = 0;
3182                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3183                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3184                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3185                         msg_ref = (uint64_t)msg_var.inner & ~1;
3186         return msg_ref;
3187 }
3188 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
3189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3190         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3191                         int8_tArray node_id_arr = init_int8_tArray(33);
3192                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
3193         return node_id_arr;
3194 }
3195 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
3196         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3197         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3198                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3199                         uint64_t msg_ref = 0;
3200                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3201                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3202                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3203                         msg_ref = (uint64_t)msg_var.inner & ~1;
3204         return msg_ref;
3205 }
3206 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
3207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3208         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3209                         int8_tArray node_id_arr = init_int8_tArray(33);
3210                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
3211         return node_id_arr;
3212 }
3213 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
3214         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3215         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3216                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3217                         uint64_t msg_ref = 0;
3218                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3219                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3220                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3221                         msg_ref = (uint64_t)msg_var.inner & ~1;
3222         return msg_ref;
3223 }
3224 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3225         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3226         for (size_t i = 0; i < ret.datalen; i++) {
3227                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3228         }
3229         return ret;
3230 }
3231 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3232 CHECK(owner->result_ok);
3233         return *owner->contents.result;
3234 }
3235 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3236         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3237         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
3238         return ret_val;
3239 }
3240
3241 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3242 CHECK(!owner->result_ok);
3243         return LightningError_clone(&*owner->contents.err);
3244 }
3245 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3246         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3247         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3248         uint64_t ret_ref = 0;
3249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3252         ret_ref = (uint64_t)ret_var.inner;
3253         if (ret_var.is_owned) {
3254                 ret_ref |= 1;
3255         }
3256         return ret_ref;
3257 }
3258
3259 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3260         return ChannelAnnouncement_clone(&owner->a);
3261 }
3262 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3263         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3264         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3265         uint64_t ret_ref = 0;
3266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3269         ret_ref = (uint64_t)ret_var.inner;
3270         if (ret_var.is_owned) {
3271                 ret_ref |= 1;
3272         }
3273         return ret_ref;
3274 }
3275
3276 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3277         return ChannelUpdate_clone(&owner->b);
3278 }
3279 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3280         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3281         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3282         uint64_t ret_ref = 0;
3283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3286         ret_ref = (uint64_t)ret_var.inner;
3287         if (ret_var.is_owned) {
3288                 ret_ref |= 1;
3289         }
3290         return ret_ref;
3291 }
3292
3293 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3294         return ChannelUpdate_clone(&owner->c);
3295 }
3296 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3297         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3298         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3299         uint64_t ret_ref = 0;
3300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3303         ret_ref = (uint64_t)ret_var.inner;
3304         if (ret_var.is_owned) {
3305                 ret_ref |= 1;
3306         }
3307         return ret_ref;
3308 }
3309
3310 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3311         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3312         for (size_t i = 0; i < ret.datalen; i++) {
3313                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3314         }
3315         return ret;
3316 }
3317 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3318         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3319         for (size_t i = 0; i < ret.datalen; i++) {
3320                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3321         }
3322         return ret;
3323 }
3324 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3325 CHECK(owner->result_ok);
3326         return CVec_u8Z_clone(&*owner->contents.result);
3327 }
3328 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
3329         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3330         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
3331         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
3332         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3333         CVec_u8Z_free(ret_var);
3334         return ret_arr;
3335 }
3336
3337 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3338 CHECK(!owner->result_ok);
3339         return PeerHandleError_clone(&*owner->contents.err);
3340 }
3341 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
3342         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3343         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
3344         uint64_t ret_ref = 0;
3345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3348         ret_ref = (uint64_t)ret_var.inner;
3349         if (ret_var.is_owned) {
3350                 ret_ref |= 1;
3351         }
3352         return ret_ref;
3353 }
3354
3355 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3356 CHECK(owner->result_ok);
3357         return *owner->contents.result;
3358 }
3359 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
3360         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3361         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
3362 }
3363
3364 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3365 CHECK(!owner->result_ok);
3366         return PeerHandleError_clone(&*owner->contents.err);
3367 }
3368 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
3369         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3370         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
3371         uint64_t ret_ref = 0;
3372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3375         ret_ref = (uint64_t)ret_var.inner;
3376         if (ret_var.is_owned) {
3377                 ret_ref |= 1;
3378         }
3379         return ret_ref;
3380 }
3381
3382 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3383 CHECK(owner->result_ok);
3384         return *owner->contents.result;
3385 }
3386 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
3387         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3388         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
3389         return ret_val;
3390 }
3391
3392 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3393 CHECK(!owner->result_ok);
3394         return PeerHandleError_clone(&*owner->contents.err);
3395 }
3396 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
3397         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3398         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
3399         uint64_t ret_ref = 0;
3400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3403         ret_ref = (uint64_t)ret_var.inner;
3404         if (ret_var.is_owned) {
3405                 ret_ref |= 1;
3406         }
3407         return ret_ref;
3408 }
3409
3410 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3411 CHECK(owner->result_ok);
3412         return TxOut_clone(&*owner->contents.result);
3413 }
3414 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
3415         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3416         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3417         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3418         return (uint64_t)ret_ref;
3419 }
3420
3421 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3422 CHECK(!owner->result_ok);
3423         return AccessError_clone(&*owner->contents.err);
3424 }
3425 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
3426         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3427         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
3428         return ret_conv;
3429 }
3430
3431 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3432 CHECK(owner->result_ok);
3433         return *owner->contents.result;
3434 }
3435 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
3436         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3437         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3438 }
3439
3440 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3441 CHECK(!owner->result_ok);
3442         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3443 }
3444 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
3445         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3446         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3447         return ret_conv;
3448 }
3449
3450 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
3451         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3452         switch(obj->tag) {
3453                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
3454                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
3455                 default: abort();
3456         }
3457 }
3458 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
3459         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3460         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
3461                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3462                         *some_conv = obj->some;
3463                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3464         return ((uint64_t)some_conv);
3465 }
3466 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
3467         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3468         switch(obj->tag) {
3469                 case LDKCOption_ClosureReasonZ_Some: return 0;
3470                 case LDKCOption_ClosureReasonZ_None: return 1;
3471                 default: abort();
3472         }
3473 }
3474 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
3475         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3476         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
3477                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
3478         return some_ref;
3479 }
3480 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3481 CHECK(owner->result_ok);
3482         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3483 }
3484 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
3485         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3486         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3487         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3488         uint64_t ret_ref = (uint64_t)ret_copy;
3489         return ret_ref;
3490 }
3491
3492 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3493 CHECK(!owner->result_ok);
3494         return DecodeError_clone(&*owner->contents.err);
3495 }
3496 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
3497         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3498         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3499         uint64_t ret_ref = 0;
3500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3503         ret_ref = (uint64_t)ret_var.inner;
3504         if (ret_var.is_owned) {
3505                 ret_ref |= 1;
3506         }
3507         return ret_ref;
3508 }
3509
3510 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
3511         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3512         switch(obj->tag) {
3513                 case LDKCOption_EventZ_Some: return 0;
3514                 case LDKCOption_EventZ_None: return 1;
3515                 default: abort();
3516         }
3517 }
3518 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
3519         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3520         assert(obj->tag == LDKCOption_EventZ_Some);
3521                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
3522         return some_ref;
3523 }
3524 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3525 CHECK(owner->result_ok);
3526         return COption_EventZ_clone(&*owner->contents.result);
3527 }
3528 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
3529         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3530         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3531         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3532         uint64_t ret_ref = (uint64_t)ret_copy;
3533         return ret_ref;
3534 }
3535
3536 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3537 CHECK(!owner->result_ok);
3538         return DecodeError_clone(&*owner->contents.err);
3539 }
3540 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
3541         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3542         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3543         uint64_t ret_ref = 0;
3544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3547         ret_ref = (uint64_t)ret_var.inner;
3548         if (ret_var.is_owned) {
3549                 ret_ref |= 1;
3550         }
3551         return ret_ref;
3552 }
3553
3554 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3555 CHECK(owner->result_ok);
3556         return NodeId_clone(&*owner->contents.result);
3557 }
3558 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3559         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3560         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3561         uint64_t ret_ref = 0;
3562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3565         ret_ref = (uint64_t)ret_var.inner;
3566         if (ret_var.is_owned) {
3567                 ret_ref |= 1;
3568         }
3569         return ret_ref;
3570 }
3571
3572 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3573 CHECK(!owner->result_ok);
3574         return DecodeError_clone(&*owner->contents.err);
3575 }
3576 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3577         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3578         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3579         uint64_t ret_ref = 0;
3580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3583         ret_ref = (uint64_t)ret_var.inner;
3584         if (ret_var.is_owned) {
3585                 ret_ref |= 1;
3586         }
3587         return ret_ref;
3588 }
3589
3590 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3591 CHECK(owner->result_ok);
3592         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3593 }
3594 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3595         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3596         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3597         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3598         uint64_t ret_ref = (uint64_t)ret_copy;
3599         return ret_ref;
3600 }
3601
3602 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3603 CHECK(!owner->result_ok);
3604         return DecodeError_clone(&*owner->contents.err);
3605 }
3606 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3607         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3608         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3609         uint64_t ret_ref = 0;
3610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3613         ret_ref = (uint64_t)ret_var.inner;
3614         if (ret_var.is_owned) {
3615                 ret_ref |= 1;
3616         }
3617         return ret_ref;
3618 }
3619
3620 typedef struct LDKAccess_JCalls {
3621         atomic_size_t refcnt;
3622         uint32_t instance_ptr;
3623 } LDKAccess_JCalls;
3624 static void LDKAccess_JCalls_free(void* this_arg) {
3625         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3626         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3627                 FREE(j_calls);
3628         }
3629 }
3630 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3631         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3632         int8_tArray genesis_hash_arr = init_int8_tArray(32);
3633         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3634         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 17, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
3635         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3636         CHECK_ACCESS(ret_ptr);
3637         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3638         FREE((void*)ret);
3639         return ret_conv;
3640 }
3641 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3642         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3643         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3644 }
3645 static inline LDKAccess LDKAccess_init (JSValue o) {
3646         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3647         atomic_init(&calls->refcnt, 1);
3648         calls->instance_ptr = o;
3649
3650         LDKAccess ret = {
3651                 .this_arg = (void*) calls,
3652                 .get_utxo = get_utxo_LDKAccess_jcall,
3653                 .free = LDKAccess_JCalls_free,
3654         };
3655         return ret;
3656 }
3657 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3658         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3659         *res_ptr = LDKAccess_init(o);
3660         return (long)res_ptr;
3661 }
3662 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) {
3663         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3665         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3666         unsigned char genesis_hash_arr[32];
3667         CHECK(genesis_hash->arr_len == 32);
3668         memcpy(genesis_hash_arr, genesis_hash->elems, 32);
3669         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3670         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3671         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3672         return (uint64_t)ret_conv;
3673 }
3674
3675 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3676         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3677         switch(obj->tag) {
3678                 case LDKCOption_AccessZ_Some: return 0;
3679                 case LDKCOption_AccessZ_None: return 1;
3680                 default: abort();
3681         }
3682 }
3683 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3684         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3685         assert(obj->tag == LDKCOption_AccessZ_Some);
3686                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3687                         *some_ret = obj->some;
3688                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
3689         return (uint64_t)some_ret;
3690 }
3691 static inline struct LDKDirectionalChannelInfo CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3692 CHECK(owner->result_ok);
3693         return DirectionalChannelInfo_clone(&*owner->contents.result);
3694 }
3695 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3696         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3697         LDKDirectionalChannelInfo ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(owner_conv);
3698         uint64_t ret_ref = 0;
3699         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3700         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3702         ret_ref = (uint64_t)ret_var.inner;
3703         if (ret_var.is_owned) {
3704                 ret_ref |= 1;
3705         }
3706         return ret_ref;
3707 }
3708
3709 static inline struct LDKDecodeError CResult_DirectionalChannelInfoDecodeErrorZ_get_err(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3710 CHECK(!owner->result_ok);
3711         return DecodeError_clone(&*owner->contents.err);
3712 }
3713 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3714         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3715         LDKDecodeError ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_err(owner_conv);
3716         uint64_t ret_ref = 0;
3717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3720         ret_ref = (uint64_t)ret_var.inner;
3721         if (ret_var.is_owned) {
3722                 ret_ref |= 1;
3723         }
3724         return ret_ref;
3725 }
3726
3727 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3728 CHECK(owner->result_ok);
3729         return ChannelInfo_clone(&*owner->contents.result);
3730 }
3731 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3732         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3733         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3734         uint64_t ret_ref = 0;
3735         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3736         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3738         ret_ref = (uint64_t)ret_var.inner;
3739         if (ret_var.is_owned) {
3740                 ret_ref |= 1;
3741         }
3742         return ret_ref;
3743 }
3744
3745 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3746 CHECK(!owner->result_ok);
3747         return DecodeError_clone(&*owner->contents.err);
3748 }
3749 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3750         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3751         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3752         uint64_t ret_ref = 0;
3753         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3754         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3756         ret_ref = (uint64_t)ret_var.inner;
3757         if (ret_var.is_owned) {
3758                 ret_ref |= 1;
3759         }
3760         return ret_ref;
3761 }
3762
3763 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3764 CHECK(owner->result_ok);
3765         return RoutingFees_clone(&*owner->contents.result);
3766 }
3767 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3768         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3769         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3770         uint64_t ret_ref = 0;
3771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3774         ret_ref = (uint64_t)ret_var.inner;
3775         if (ret_var.is_owned) {
3776                 ret_ref |= 1;
3777         }
3778         return ret_ref;
3779 }
3780
3781 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3782 CHECK(!owner->result_ok);
3783         return DecodeError_clone(&*owner->contents.err);
3784 }
3785 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3786         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3787         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3788         uint64_t ret_ref = 0;
3789         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3790         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3792         ret_ref = (uint64_t)ret_var.inner;
3793         if (ret_var.is_owned) {
3794                 ret_ref |= 1;
3795         }
3796         return ret_ref;
3797 }
3798
3799 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3800         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3801         switch(obj->tag) {
3802                 case LDKNetAddress_IPv4: return 0;
3803                 case LDKNetAddress_IPv6: return 1;
3804                 case LDKNetAddress_OnionV2: return 2;
3805                 case LDKNetAddress_OnionV3: return 3;
3806                 default: abort();
3807         }
3808 }
3809 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3810         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3811         assert(obj->tag == LDKNetAddress_IPv4);
3812                         int8_tArray addr_arr = init_int8_tArray(4);
3813                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3814         return addr_arr;
3815 }
3816 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3817         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3818         assert(obj->tag == LDKNetAddress_IPv4);
3819         return obj->i_pv4.port;
3820 }
3821 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3822         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3823         assert(obj->tag == LDKNetAddress_IPv6);
3824                         int8_tArray addr_arr = init_int8_tArray(16);
3825                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3826         return addr_arr;
3827 }
3828 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3829         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3830         assert(obj->tag == LDKNetAddress_IPv6);
3831         return obj->i_pv6.port;
3832 }
3833 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3834         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3835         assert(obj->tag == LDKNetAddress_OnionV2);
3836                         int8_tArray onion_v2_arr = init_int8_tArray(12);
3837                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3838         return onion_v2_arr;
3839 }
3840 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3841         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3842         assert(obj->tag == LDKNetAddress_OnionV3);
3843                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32);
3844                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3845         return ed25519_pubkey_arr;
3846 }
3847 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3848         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3849         assert(obj->tag == LDKNetAddress_OnionV3);
3850         return obj->onion_v3.checksum;
3851 }
3852 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3853         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3854         assert(obj->tag == LDKNetAddress_OnionV3);
3855         return obj->onion_v3.version;
3856 }
3857 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3858         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3859         assert(obj->tag == LDKNetAddress_OnionV3);
3860         return obj->onion_v3.port;
3861 }
3862 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3863         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3864         for (size_t i = 0; i < ret.datalen; i++) {
3865                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3866         }
3867         return ret;
3868 }
3869 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3870 CHECK(owner->result_ok);
3871         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3872 }
3873 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3874         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3875         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3876         uint64_t ret_ref = 0;
3877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3880         ret_ref = (uint64_t)ret_var.inner;
3881         if (ret_var.is_owned) {
3882                 ret_ref |= 1;
3883         }
3884         return ret_ref;
3885 }
3886
3887 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3888 CHECK(!owner->result_ok);
3889         return DecodeError_clone(&*owner->contents.err);
3890 }
3891 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3892         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3893         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3894         uint64_t ret_ref = 0;
3895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3898         ret_ref = (uint64_t)ret_var.inner;
3899         if (ret_var.is_owned) {
3900                 ret_ref |= 1;
3901         }
3902         return ret_ref;
3903 }
3904
3905 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3906         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3907         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3908         return ret;
3909 }
3910 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3911 CHECK(owner->result_ok);
3912         return NodeInfo_clone(&*owner->contents.result);
3913 }
3914 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3915         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3916         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3917         uint64_t ret_ref = 0;
3918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3921         ret_ref = (uint64_t)ret_var.inner;
3922         if (ret_var.is_owned) {
3923                 ret_ref |= 1;
3924         }
3925         return ret_ref;
3926 }
3927
3928 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3929 CHECK(!owner->result_ok);
3930         return DecodeError_clone(&*owner->contents.err);
3931 }
3932 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3933         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3934         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3935         uint64_t ret_ref = 0;
3936         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3937         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3939         ret_ref = (uint64_t)ret_var.inner;
3940         if (ret_var.is_owned) {
3941                 ret_ref |= 1;
3942         }
3943         return ret_ref;
3944 }
3945
3946 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3947 CHECK(owner->result_ok);
3948         return NetworkGraph_clone(&*owner->contents.result);
3949 }
3950 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3951         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3952         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3953         uint64_t ret_ref = 0;
3954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3957         ret_ref = (uint64_t)ret_var.inner;
3958         if (ret_var.is_owned) {
3959                 ret_ref |= 1;
3960         }
3961         return ret_ref;
3962 }
3963
3964 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3965 CHECK(!owner->result_ok);
3966         return DecodeError_clone(&*owner->contents.err);
3967 }
3968 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3969         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3970         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3971         uint64_t ret_ref = 0;
3972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3975         ret_ref = (uint64_t)ret_var.inner;
3976         if (ret_var.is_owned) {
3977                 ret_ref |= 1;
3978         }
3979         return ret_ref;
3980 }
3981
3982 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3983         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3984         switch(obj->tag) {
3985                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3986                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3987                 default: abort();
3988         }
3989 }
3990 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3991         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3992         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3993                         LDKCVec_NetAddressZ some_var = obj->some;
3994                         uint32_tArray some_arr = NULL;
3995                         some_arr = init_uint32_tArray(some_var.datalen);
3996                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
3997                         for (size_t m = 0; m < some_var.datalen; m++) {
3998                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
3999                                 some_arr_ptr[m] = some_conv_12_ref;
4000                         }
4001                         
4002         return some_arr;
4003 }
4004 static inline struct LDKScoringParameters *CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4005 CHECK(owner->result_ok);
4006         return &*owner->contents.result;
4007 }
4008 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
4009         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4010         LDKScoringParameters ret_var = *CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
4011         uint64_t ret_ref = 0;
4012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4015         ret_ref = (uint64_t)ret_var.inner & ~1;
4016         return ret_ref;
4017 }
4018
4019 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4020 CHECK(!owner->result_ok);
4021         return DecodeError_clone(&*owner->contents.err);
4022 }
4023 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
4024         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4025         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
4026         uint64_t ret_ref = 0;
4027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4030         ret_ref = (uint64_t)ret_var.inner;
4031         if (ret_var.is_owned) {
4032                 ret_ref |= 1;
4033         }
4034         return ret_ref;
4035 }
4036
4037 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4038 CHECK(owner->result_ok);
4039         return InitFeatures_clone(&*owner->contents.result);
4040 }
4041 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4042         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4043         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4044         uint64_t ret_ref = 0;
4045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4048         ret_ref = (uint64_t)ret_var.inner;
4049         if (ret_var.is_owned) {
4050                 ret_ref |= 1;
4051         }
4052         return ret_ref;
4053 }
4054
4055 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4056 CHECK(!owner->result_ok);
4057         return DecodeError_clone(&*owner->contents.err);
4058 }
4059 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4060         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4061         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4062         uint64_t ret_ref = 0;
4063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4066         ret_ref = (uint64_t)ret_var.inner;
4067         if (ret_var.is_owned) {
4068                 ret_ref |= 1;
4069         }
4070         return ret_ref;
4071 }
4072
4073 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4074 CHECK(owner->result_ok);
4075         return ChannelFeatures_clone(&*owner->contents.result);
4076 }
4077 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4078         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4079         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4080         uint64_t ret_ref = 0;
4081         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4082         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4084         ret_ref = (uint64_t)ret_var.inner;
4085         if (ret_var.is_owned) {
4086                 ret_ref |= 1;
4087         }
4088         return ret_ref;
4089 }
4090
4091 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4092 CHECK(!owner->result_ok);
4093         return DecodeError_clone(&*owner->contents.err);
4094 }
4095 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4096         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4097         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4098         uint64_t ret_ref = 0;
4099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4102         ret_ref = (uint64_t)ret_var.inner;
4103         if (ret_var.is_owned) {
4104                 ret_ref |= 1;
4105         }
4106         return ret_ref;
4107 }
4108
4109 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4110 CHECK(owner->result_ok);
4111         return NodeFeatures_clone(&*owner->contents.result);
4112 }
4113 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4114         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4115         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4116         uint64_t ret_ref = 0;
4117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4120         ret_ref = (uint64_t)ret_var.inner;
4121         if (ret_var.is_owned) {
4122                 ret_ref |= 1;
4123         }
4124         return ret_ref;
4125 }
4126
4127 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4128 CHECK(!owner->result_ok);
4129         return DecodeError_clone(&*owner->contents.err);
4130 }
4131 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4132         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4133         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4134         uint64_t ret_ref = 0;
4135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4138         ret_ref = (uint64_t)ret_var.inner;
4139         if (ret_var.is_owned) {
4140                 ret_ref |= 1;
4141         }
4142         return ret_ref;
4143 }
4144
4145 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4146 CHECK(owner->result_ok);
4147         return InvoiceFeatures_clone(&*owner->contents.result);
4148 }
4149 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4150         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4151         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4152         uint64_t ret_ref = 0;
4153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4156         ret_ref = (uint64_t)ret_var.inner;
4157         if (ret_var.is_owned) {
4158                 ret_ref |= 1;
4159         }
4160         return ret_ref;
4161 }
4162
4163 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4164 CHECK(!owner->result_ok);
4165         return DecodeError_clone(&*owner->contents.err);
4166 }
4167 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4168         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4169         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4170         uint64_t ret_ref = 0;
4171         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4172         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4174         ret_ref = (uint64_t)ret_var.inner;
4175         if (ret_var.is_owned) {
4176                 ret_ref |= 1;
4177         }
4178         return ret_ref;
4179 }
4180
4181 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4182 CHECK(owner->result_ok);
4183         return ChannelTypeFeatures_clone(&*owner->contents.result);
4184 }
4185 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4186         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4187         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4188         uint64_t ret_ref = 0;
4189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4192         ret_ref = (uint64_t)ret_var.inner;
4193         if (ret_var.is_owned) {
4194                 ret_ref |= 1;
4195         }
4196         return ret_ref;
4197 }
4198
4199 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4200 CHECK(!owner->result_ok);
4201         return DecodeError_clone(&*owner->contents.err);
4202 }
4203 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4204         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4205         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4206         uint64_t ret_ref = 0;
4207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4210         ret_ref = (uint64_t)ret_var.inner;
4211         if (ret_var.is_owned) {
4212                 ret_ref |= 1;
4213         }
4214         return ret_ref;
4215 }
4216
4217 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4218 CHECK(owner->result_ok);
4219         return NetAddress_clone(&*owner->contents.result);
4220 }
4221 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
4222         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4223         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
4224         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
4225         uint64_t ret_ref = (uint64_t)ret_copy;
4226         return ret_ref;
4227 }
4228
4229 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4230 CHECK(!owner->result_ok);
4231         return DecodeError_clone(&*owner->contents.err);
4232 }
4233 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
4234         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4235         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
4236         uint64_t ret_ref = 0;
4237         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4238         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4240         ret_ref = (uint64_t)ret_var.inner;
4241         if (ret_var.is_owned) {
4242                 ret_ref |= 1;
4243         }
4244         return ret_ref;
4245 }
4246
4247 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4248         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4249         for (size_t i = 0; i < ret.datalen; i++) {
4250                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4251         }
4252         return ret;
4253 }
4254 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4255         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4256         for (size_t i = 0; i < ret.datalen; i++) {
4257                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4258         }
4259         return ret;
4260 }
4261 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4262         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4263         for (size_t i = 0; i < ret.datalen; i++) {
4264                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4265         }
4266         return ret;
4267 }
4268 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4269         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4270         for (size_t i = 0; i < ret.datalen; i++) {
4271                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4272         }
4273         return ret;
4274 }
4275 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4276 CHECK(owner->result_ok);
4277         return AcceptChannel_clone(&*owner->contents.result);
4278 }
4279 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
4280         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4281         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
4282         uint64_t ret_ref = 0;
4283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4286         ret_ref = (uint64_t)ret_var.inner;
4287         if (ret_var.is_owned) {
4288                 ret_ref |= 1;
4289         }
4290         return ret_ref;
4291 }
4292
4293 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4294 CHECK(!owner->result_ok);
4295         return DecodeError_clone(&*owner->contents.err);
4296 }
4297 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
4298         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4299         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
4300         uint64_t ret_ref = 0;
4301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4304         ret_ref = (uint64_t)ret_var.inner;
4305         if (ret_var.is_owned) {
4306                 ret_ref |= 1;
4307         }
4308         return ret_ref;
4309 }
4310
4311 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4312 CHECK(owner->result_ok);
4313         return AnnouncementSignatures_clone(&*owner->contents.result);
4314 }
4315 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
4316         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4317         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
4318         uint64_t ret_ref = 0;
4319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4322         ret_ref = (uint64_t)ret_var.inner;
4323         if (ret_var.is_owned) {
4324                 ret_ref |= 1;
4325         }
4326         return ret_ref;
4327 }
4328
4329 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4330 CHECK(!owner->result_ok);
4331         return DecodeError_clone(&*owner->contents.err);
4332 }
4333 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
4334         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4335         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
4336         uint64_t ret_ref = 0;
4337         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4338         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4340         ret_ref = (uint64_t)ret_var.inner;
4341         if (ret_var.is_owned) {
4342                 ret_ref |= 1;
4343         }
4344         return ret_ref;
4345 }
4346
4347 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4348 CHECK(owner->result_ok);
4349         return ChannelReestablish_clone(&*owner->contents.result);
4350 }
4351 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
4352         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4353         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
4354         uint64_t ret_ref = 0;
4355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4358         ret_ref = (uint64_t)ret_var.inner;
4359         if (ret_var.is_owned) {
4360                 ret_ref |= 1;
4361         }
4362         return ret_ref;
4363 }
4364
4365 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4366 CHECK(!owner->result_ok);
4367         return DecodeError_clone(&*owner->contents.err);
4368 }
4369 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
4370         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4371         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
4372         uint64_t ret_ref = 0;
4373         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4374         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4376         ret_ref = (uint64_t)ret_var.inner;
4377         if (ret_var.is_owned) {
4378                 ret_ref |= 1;
4379         }
4380         return ret_ref;
4381 }
4382
4383 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4384 CHECK(owner->result_ok);
4385         return ClosingSigned_clone(&*owner->contents.result);
4386 }
4387 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4388         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4389         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
4390         uint64_t ret_ref = 0;
4391         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4392         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4394         ret_ref = (uint64_t)ret_var.inner;
4395         if (ret_var.is_owned) {
4396                 ret_ref |= 1;
4397         }
4398         return ret_ref;
4399 }
4400
4401 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4402 CHECK(!owner->result_ok);
4403         return DecodeError_clone(&*owner->contents.err);
4404 }
4405 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
4406         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4407         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
4408         uint64_t ret_ref = 0;
4409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4412         ret_ref = (uint64_t)ret_var.inner;
4413         if (ret_var.is_owned) {
4414                 ret_ref |= 1;
4415         }
4416         return ret_ref;
4417 }
4418
4419 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4420 CHECK(owner->result_ok);
4421         return ClosingSignedFeeRange_clone(&*owner->contents.result);
4422 }
4423 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
4424         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4425         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
4426         uint64_t ret_ref = 0;
4427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4430         ret_ref = (uint64_t)ret_var.inner;
4431         if (ret_var.is_owned) {
4432                 ret_ref |= 1;
4433         }
4434         return ret_ref;
4435 }
4436
4437 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4438 CHECK(!owner->result_ok);
4439         return DecodeError_clone(&*owner->contents.err);
4440 }
4441 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
4442         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4443         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
4444         uint64_t ret_ref = 0;
4445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4448         ret_ref = (uint64_t)ret_var.inner;
4449         if (ret_var.is_owned) {
4450                 ret_ref |= 1;
4451         }
4452         return ret_ref;
4453 }
4454
4455 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4456 CHECK(owner->result_ok);
4457         return CommitmentSigned_clone(&*owner->contents.result);
4458 }
4459 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
4460         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4461         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
4462         uint64_t ret_ref = 0;
4463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4466         ret_ref = (uint64_t)ret_var.inner;
4467         if (ret_var.is_owned) {
4468                 ret_ref |= 1;
4469         }
4470         return ret_ref;
4471 }
4472
4473 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4474 CHECK(!owner->result_ok);
4475         return DecodeError_clone(&*owner->contents.err);
4476 }
4477 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
4478         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4479         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
4480         uint64_t ret_ref = 0;
4481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4482         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4484         ret_ref = (uint64_t)ret_var.inner;
4485         if (ret_var.is_owned) {
4486                 ret_ref |= 1;
4487         }
4488         return ret_ref;
4489 }
4490
4491 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4492 CHECK(owner->result_ok);
4493         return FundingCreated_clone(&*owner->contents.result);
4494 }
4495 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
4496         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4497         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
4498         uint64_t ret_ref = 0;
4499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4502         ret_ref = (uint64_t)ret_var.inner;
4503         if (ret_var.is_owned) {
4504                 ret_ref |= 1;
4505         }
4506         return ret_ref;
4507 }
4508
4509 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4510 CHECK(!owner->result_ok);
4511         return DecodeError_clone(&*owner->contents.err);
4512 }
4513 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
4514         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4515         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
4516         uint64_t ret_ref = 0;
4517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4520         ret_ref = (uint64_t)ret_var.inner;
4521         if (ret_var.is_owned) {
4522                 ret_ref |= 1;
4523         }
4524         return ret_ref;
4525 }
4526
4527 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4528 CHECK(owner->result_ok);
4529         return FundingSigned_clone(&*owner->contents.result);
4530 }
4531 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4532         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4533         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
4534         uint64_t ret_ref = 0;
4535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4538         ret_ref = (uint64_t)ret_var.inner;
4539         if (ret_var.is_owned) {
4540                 ret_ref |= 1;
4541         }
4542         return ret_ref;
4543 }
4544
4545 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4546 CHECK(!owner->result_ok);
4547         return DecodeError_clone(&*owner->contents.err);
4548 }
4549 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
4550         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4551         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
4552         uint64_t ret_ref = 0;
4553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4556         ret_ref = (uint64_t)ret_var.inner;
4557         if (ret_var.is_owned) {
4558                 ret_ref |= 1;
4559         }
4560         return ret_ref;
4561 }
4562
4563 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4564 CHECK(owner->result_ok);
4565         return FundingLocked_clone(&*owner->contents.result);
4566 }
4567 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
4568         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4569         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
4570         uint64_t ret_ref = 0;
4571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4574         ret_ref = (uint64_t)ret_var.inner;
4575         if (ret_var.is_owned) {
4576                 ret_ref |= 1;
4577         }
4578         return ret_ref;
4579 }
4580
4581 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4582 CHECK(!owner->result_ok);
4583         return DecodeError_clone(&*owner->contents.err);
4584 }
4585 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
4586         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4587         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
4588         uint64_t ret_ref = 0;
4589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4592         ret_ref = (uint64_t)ret_var.inner;
4593         if (ret_var.is_owned) {
4594                 ret_ref |= 1;
4595         }
4596         return ret_ref;
4597 }
4598
4599 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4600 CHECK(owner->result_ok);
4601         return Init_clone(&*owner->contents.result);
4602 }
4603 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
4604         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4605         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
4606         uint64_t ret_ref = 0;
4607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4610         ret_ref = (uint64_t)ret_var.inner;
4611         if (ret_var.is_owned) {
4612                 ret_ref |= 1;
4613         }
4614         return ret_ref;
4615 }
4616
4617 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4618 CHECK(!owner->result_ok);
4619         return DecodeError_clone(&*owner->contents.err);
4620 }
4621 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
4622         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4623         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
4624         uint64_t ret_ref = 0;
4625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4628         ret_ref = (uint64_t)ret_var.inner;
4629         if (ret_var.is_owned) {
4630                 ret_ref |= 1;
4631         }
4632         return ret_ref;
4633 }
4634
4635 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4636 CHECK(owner->result_ok);
4637         return OpenChannel_clone(&*owner->contents.result);
4638 }
4639 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
4640         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4641         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
4642         uint64_t ret_ref = 0;
4643         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4644         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4646         ret_ref = (uint64_t)ret_var.inner;
4647         if (ret_var.is_owned) {
4648                 ret_ref |= 1;
4649         }
4650         return ret_ref;
4651 }
4652
4653 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4654 CHECK(!owner->result_ok);
4655         return DecodeError_clone(&*owner->contents.err);
4656 }
4657 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
4658         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4659         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
4660         uint64_t ret_ref = 0;
4661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4664         ret_ref = (uint64_t)ret_var.inner;
4665         if (ret_var.is_owned) {
4666                 ret_ref |= 1;
4667         }
4668         return ret_ref;
4669 }
4670
4671 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4672 CHECK(owner->result_ok);
4673         return RevokeAndACK_clone(&*owner->contents.result);
4674 }
4675 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
4676         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4677         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
4678         uint64_t ret_ref = 0;
4679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4682         ret_ref = (uint64_t)ret_var.inner;
4683         if (ret_var.is_owned) {
4684                 ret_ref |= 1;
4685         }
4686         return ret_ref;
4687 }
4688
4689 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4690 CHECK(!owner->result_ok);
4691         return DecodeError_clone(&*owner->contents.err);
4692 }
4693 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
4694         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4695         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
4696         uint64_t ret_ref = 0;
4697         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4698         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4700         ret_ref = (uint64_t)ret_var.inner;
4701         if (ret_var.is_owned) {
4702                 ret_ref |= 1;
4703         }
4704         return ret_ref;
4705 }
4706
4707 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4708 CHECK(owner->result_ok);
4709         return Shutdown_clone(&*owner->contents.result);
4710 }
4711 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
4712         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4713         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
4714         uint64_t ret_ref = 0;
4715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4718         ret_ref = (uint64_t)ret_var.inner;
4719         if (ret_var.is_owned) {
4720                 ret_ref |= 1;
4721         }
4722         return ret_ref;
4723 }
4724
4725 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4726 CHECK(!owner->result_ok);
4727         return DecodeError_clone(&*owner->contents.err);
4728 }
4729 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
4730         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4731         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
4732         uint64_t ret_ref = 0;
4733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4736         ret_ref = (uint64_t)ret_var.inner;
4737         if (ret_var.is_owned) {
4738                 ret_ref |= 1;
4739         }
4740         return ret_ref;
4741 }
4742
4743 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4744 CHECK(owner->result_ok);
4745         return UpdateFailHTLC_clone(&*owner->contents.result);
4746 }
4747 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4748         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4749         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
4750         uint64_t ret_ref = 0;
4751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4754         ret_ref = (uint64_t)ret_var.inner;
4755         if (ret_var.is_owned) {
4756                 ret_ref |= 1;
4757         }
4758         return ret_ref;
4759 }
4760
4761 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4762 CHECK(!owner->result_ok);
4763         return DecodeError_clone(&*owner->contents.err);
4764 }
4765 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
4766         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4767         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
4768         uint64_t ret_ref = 0;
4769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4772         ret_ref = (uint64_t)ret_var.inner;
4773         if (ret_var.is_owned) {
4774                 ret_ref |= 1;
4775         }
4776         return ret_ref;
4777 }
4778
4779 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4780 CHECK(owner->result_ok);
4781         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
4782 }
4783 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4784         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4785         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
4786         uint64_t ret_ref = 0;
4787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4790         ret_ref = (uint64_t)ret_var.inner;
4791         if (ret_var.is_owned) {
4792                 ret_ref |= 1;
4793         }
4794         return ret_ref;
4795 }
4796
4797 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4798 CHECK(!owner->result_ok);
4799         return DecodeError_clone(&*owner->contents.err);
4800 }
4801 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
4802         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4803         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
4804         uint64_t ret_ref = 0;
4805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4808         ret_ref = (uint64_t)ret_var.inner;
4809         if (ret_var.is_owned) {
4810                 ret_ref |= 1;
4811         }
4812         return ret_ref;
4813 }
4814
4815 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4816 CHECK(owner->result_ok);
4817         return UpdateFee_clone(&*owner->contents.result);
4818 }
4819 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
4820         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4821         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
4822         uint64_t ret_ref = 0;
4823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4826         ret_ref = (uint64_t)ret_var.inner;
4827         if (ret_var.is_owned) {
4828                 ret_ref |= 1;
4829         }
4830         return ret_ref;
4831 }
4832
4833 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4834 CHECK(!owner->result_ok);
4835         return DecodeError_clone(&*owner->contents.err);
4836 }
4837 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
4838         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4839         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
4840         uint64_t ret_ref = 0;
4841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4844         ret_ref = (uint64_t)ret_var.inner;
4845         if (ret_var.is_owned) {
4846                 ret_ref |= 1;
4847         }
4848         return ret_ref;
4849 }
4850
4851 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4852 CHECK(owner->result_ok);
4853         return UpdateFulfillHTLC_clone(&*owner->contents.result);
4854 }
4855 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4856         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4857         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
4858         uint64_t ret_ref = 0;
4859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4862         ret_ref = (uint64_t)ret_var.inner;
4863         if (ret_var.is_owned) {
4864                 ret_ref |= 1;
4865         }
4866         return ret_ref;
4867 }
4868
4869 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4870 CHECK(!owner->result_ok);
4871         return DecodeError_clone(&*owner->contents.err);
4872 }
4873 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
4874         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4875         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
4876         uint64_t ret_ref = 0;
4877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4880         ret_ref = (uint64_t)ret_var.inner;
4881         if (ret_var.is_owned) {
4882                 ret_ref |= 1;
4883         }
4884         return ret_ref;
4885 }
4886
4887 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4888 CHECK(owner->result_ok);
4889         return UpdateAddHTLC_clone(&*owner->contents.result);
4890 }
4891 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4892         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4893         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
4894         uint64_t ret_ref = 0;
4895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4898         ret_ref = (uint64_t)ret_var.inner;
4899         if (ret_var.is_owned) {
4900                 ret_ref |= 1;
4901         }
4902         return ret_ref;
4903 }
4904
4905 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4906 CHECK(!owner->result_ok);
4907         return DecodeError_clone(&*owner->contents.err);
4908 }
4909 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
4910         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4911         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
4912         uint64_t ret_ref = 0;
4913         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4914         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4916         ret_ref = (uint64_t)ret_var.inner;
4917         if (ret_var.is_owned) {
4918                 ret_ref |= 1;
4919         }
4920         return ret_ref;
4921 }
4922
4923 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4924 CHECK(owner->result_ok);
4925         return Ping_clone(&*owner->contents.result);
4926 }
4927 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
4928         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4929         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
4930         uint64_t ret_ref = 0;
4931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4934         ret_ref = (uint64_t)ret_var.inner;
4935         if (ret_var.is_owned) {
4936                 ret_ref |= 1;
4937         }
4938         return ret_ref;
4939 }
4940
4941 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4942 CHECK(!owner->result_ok);
4943         return DecodeError_clone(&*owner->contents.err);
4944 }
4945 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
4946         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4947         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
4948         uint64_t ret_ref = 0;
4949         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4950         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4952         ret_ref = (uint64_t)ret_var.inner;
4953         if (ret_var.is_owned) {
4954                 ret_ref |= 1;
4955         }
4956         return ret_ref;
4957 }
4958
4959 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4960 CHECK(owner->result_ok);
4961         return Pong_clone(&*owner->contents.result);
4962 }
4963 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
4964         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4965         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
4966         uint64_t ret_ref = 0;
4967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4970         ret_ref = (uint64_t)ret_var.inner;
4971         if (ret_var.is_owned) {
4972                 ret_ref |= 1;
4973         }
4974         return ret_ref;
4975 }
4976
4977 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4978 CHECK(!owner->result_ok);
4979         return DecodeError_clone(&*owner->contents.err);
4980 }
4981 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
4982         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4983         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
4984         uint64_t ret_ref = 0;
4985         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4986         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4988         ret_ref = (uint64_t)ret_var.inner;
4989         if (ret_var.is_owned) {
4990                 ret_ref |= 1;
4991         }
4992         return ret_ref;
4993 }
4994
4995 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
4996 CHECK(owner->result_ok);
4997         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
4998 }
4999 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5000         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5001         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5002         uint64_t ret_ref = 0;
5003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5006         ret_ref = (uint64_t)ret_var.inner;
5007         if (ret_var.is_owned) {
5008                 ret_ref |= 1;
5009         }
5010         return ret_ref;
5011 }
5012
5013 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5014 CHECK(!owner->result_ok);
5015         return DecodeError_clone(&*owner->contents.err);
5016 }
5017 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5018         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5019         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5020         uint64_t ret_ref = 0;
5021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5024         ret_ref = (uint64_t)ret_var.inner;
5025         if (ret_var.is_owned) {
5026                 ret_ref |= 1;
5027         }
5028         return ret_ref;
5029 }
5030
5031 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5032 CHECK(owner->result_ok);
5033         return ChannelAnnouncement_clone(&*owner->contents.result);
5034 }
5035 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5036         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5037         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5038         uint64_t ret_ref = 0;
5039         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5040         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5042         ret_ref = (uint64_t)ret_var.inner;
5043         if (ret_var.is_owned) {
5044                 ret_ref |= 1;
5045         }
5046         return ret_ref;
5047 }
5048
5049 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5050 CHECK(!owner->result_ok);
5051         return DecodeError_clone(&*owner->contents.err);
5052 }
5053 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5054         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5055         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5056         uint64_t ret_ref = 0;
5057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5060         ret_ref = (uint64_t)ret_var.inner;
5061         if (ret_var.is_owned) {
5062                 ret_ref |= 1;
5063         }
5064         return ret_ref;
5065 }
5066
5067 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5068 CHECK(owner->result_ok);
5069         return UnsignedChannelUpdate_clone(&*owner->contents.result);
5070 }
5071 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5072         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5073         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5074         uint64_t ret_ref = 0;
5075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5078         ret_ref = (uint64_t)ret_var.inner;
5079         if (ret_var.is_owned) {
5080                 ret_ref |= 1;
5081         }
5082         return ret_ref;
5083 }
5084
5085 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5086 CHECK(!owner->result_ok);
5087         return DecodeError_clone(&*owner->contents.err);
5088 }
5089 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5090         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5091         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
5092         uint64_t ret_ref = 0;
5093         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5094         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5096         ret_ref = (uint64_t)ret_var.inner;
5097         if (ret_var.is_owned) {
5098                 ret_ref |= 1;
5099         }
5100         return ret_ref;
5101 }
5102
5103 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5104 CHECK(owner->result_ok);
5105         return ChannelUpdate_clone(&*owner->contents.result);
5106 }
5107 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5108         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5109         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5110         uint64_t ret_ref = 0;
5111         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5112         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5114         ret_ref = (uint64_t)ret_var.inner;
5115         if (ret_var.is_owned) {
5116                 ret_ref |= 1;
5117         }
5118         return ret_ref;
5119 }
5120
5121 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5122 CHECK(!owner->result_ok);
5123         return DecodeError_clone(&*owner->contents.err);
5124 }
5125 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5126         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5127         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
5128         uint64_t ret_ref = 0;
5129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5132         ret_ref = (uint64_t)ret_var.inner;
5133         if (ret_var.is_owned) {
5134                 ret_ref |= 1;
5135         }
5136         return ret_ref;
5137 }
5138
5139 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5140 CHECK(owner->result_ok);
5141         return ErrorMessage_clone(&*owner->contents.result);
5142 }
5143 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
5144         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5145         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
5146         uint64_t ret_ref = 0;
5147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5150         ret_ref = (uint64_t)ret_var.inner;
5151         if (ret_var.is_owned) {
5152                 ret_ref |= 1;
5153         }
5154         return ret_ref;
5155 }
5156
5157 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5158 CHECK(!owner->result_ok);
5159         return DecodeError_clone(&*owner->contents.err);
5160 }
5161 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
5162         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5163         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
5164         uint64_t ret_ref = 0;
5165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5168         ret_ref = (uint64_t)ret_var.inner;
5169         if (ret_var.is_owned) {
5170                 ret_ref |= 1;
5171         }
5172         return ret_ref;
5173 }
5174
5175 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5176 CHECK(owner->result_ok);
5177         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
5178 }
5179 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5180         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5181         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5182         uint64_t ret_ref = 0;
5183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5186         ret_ref = (uint64_t)ret_var.inner;
5187         if (ret_var.is_owned) {
5188                 ret_ref |= 1;
5189         }
5190         return ret_ref;
5191 }
5192
5193 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5194 CHECK(!owner->result_ok);
5195         return DecodeError_clone(&*owner->contents.err);
5196 }
5197 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5198         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5199         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5200         uint64_t ret_ref = 0;
5201         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5202         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5204         ret_ref = (uint64_t)ret_var.inner;
5205         if (ret_var.is_owned) {
5206                 ret_ref |= 1;
5207         }
5208         return ret_ref;
5209 }
5210
5211 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5212 CHECK(owner->result_ok);
5213         return NodeAnnouncement_clone(&*owner->contents.result);
5214 }
5215 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5216         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5217         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5218         uint64_t ret_ref = 0;
5219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5222         ret_ref = (uint64_t)ret_var.inner;
5223         if (ret_var.is_owned) {
5224                 ret_ref |= 1;
5225         }
5226         return ret_ref;
5227 }
5228
5229 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5230 CHECK(!owner->result_ok);
5231         return DecodeError_clone(&*owner->contents.err);
5232 }
5233 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5234         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5235         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5236         uint64_t ret_ref = 0;
5237         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5238         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5240         ret_ref = (uint64_t)ret_var.inner;
5241         if (ret_var.is_owned) {
5242                 ret_ref |= 1;
5243         }
5244         return ret_ref;
5245 }
5246
5247 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5248 CHECK(owner->result_ok);
5249         return QueryShortChannelIds_clone(&*owner->contents.result);
5250 }
5251 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
5252         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5253         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
5254         uint64_t ret_ref = 0;
5255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5258         ret_ref = (uint64_t)ret_var.inner;
5259         if (ret_var.is_owned) {
5260                 ret_ref |= 1;
5261         }
5262         return ret_ref;
5263 }
5264
5265 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5266 CHECK(!owner->result_ok);
5267         return DecodeError_clone(&*owner->contents.err);
5268 }
5269 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
5270         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5271         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
5272         uint64_t ret_ref = 0;
5273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5276         ret_ref = (uint64_t)ret_var.inner;
5277         if (ret_var.is_owned) {
5278                 ret_ref |= 1;
5279         }
5280         return ret_ref;
5281 }
5282
5283 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5284 CHECK(owner->result_ok);
5285         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
5286 }
5287 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
5288         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5289         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
5290         uint64_t ret_ref = 0;
5291         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5294         ret_ref = (uint64_t)ret_var.inner;
5295         if (ret_var.is_owned) {
5296                 ret_ref |= 1;
5297         }
5298         return ret_ref;
5299 }
5300
5301 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5302 CHECK(!owner->result_ok);
5303         return DecodeError_clone(&*owner->contents.err);
5304 }
5305 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
5306         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5307         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
5308         uint64_t ret_ref = 0;
5309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5312         ret_ref = (uint64_t)ret_var.inner;
5313         if (ret_var.is_owned) {
5314                 ret_ref |= 1;
5315         }
5316         return ret_ref;
5317 }
5318
5319 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5320 CHECK(owner->result_ok);
5321         return QueryChannelRange_clone(&*owner->contents.result);
5322 }
5323 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5324         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5325         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
5326         uint64_t ret_ref = 0;
5327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5330         ret_ref = (uint64_t)ret_var.inner;
5331         if (ret_var.is_owned) {
5332                 ret_ref |= 1;
5333         }
5334         return ret_ref;
5335 }
5336
5337 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5338 CHECK(!owner->result_ok);
5339         return DecodeError_clone(&*owner->contents.err);
5340 }
5341 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5342         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5343         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
5344         uint64_t ret_ref = 0;
5345         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5346         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5348         ret_ref = (uint64_t)ret_var.inner;
5349         if (ret_var.is_owned) {
5350                 ret_ref |= 1;
5351         }
5352         return ret_ref;
5353 }
5354
5355 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5356 CHECK(owner->result_ok);
5357         return ReplyChannelRange_clone(&*owner->contents.result);
5358 }
5359 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5360         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5361         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
5362         uint64_t ret_ref = 0;
5363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5366         ret_ref = (uint64_t)ret_var.inner;
5367         if (ret_var.is_owned) {
5368                 ret_ref |= 1;
5369         }
5370         return ret_ref;
5371 }
5372
5373 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5374 CHECK(!owner->result_ok);
5375         return DecodeError_clone(&*owner->contents.err);
5376 }
5377 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5378         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5379         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
5380         uint64_t ret_ref = 0;
5381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5384         ret_ref = (uint64_t)ret_var.inner;
5385         if (ret_var.is_owned) {
5386                 ret_ref |= 1;
5387         }
5388         return ret_ref;
5389 }
5390
5391 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5392 CHECK(owner->result_ok);
5393         return GossipTimestampFilter_clone(&*owner->contents.result);
5394 }
5395 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
5396         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5397         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
5398         uint64_t ret_ref = 0;
5399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5402         ret_ref = (uint64_t)ret_var.inner;
5403         if (ret_var.is_owned) {
5404                 ret_ref |= 1;
5405         }
5406         return ret_ref;
5407 }
5408
5409 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5410 CHECK(!owner->result_ok);
5411         return DecodeError_clone(&*owner->contents.err);
5412 }
5413 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
5414         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5415         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
5416         uint64_t ret_ref = 0;
5417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5420         ret_ref = (uint64_t)ret_var.inner;
5421         if (ret_var.is_owned) {
5422                 ret_ref |= 1;
5423         }
5424         return ret_ref;
5425 }
5426
5427 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5428 CHECK(owner->result_ok);
5429         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
5430 }
5431 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5432         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5433         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5434         uint64_t ret_ref = 0;
5435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5438         ret_ref = (uint64_t)ret_var.inner;
5439         if (ret_var.is_owned) {
5440                 ret_ref |= 1;
5441         }
5442         return ret_ref;
5443 }
5444
5445 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5446 CHECK(!owner->result_ok);
5447         return DecodeError_clone(&*owner->contents.err);
5448 }
5449 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5450         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5451         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5452         uint64_t ret_ref = 0;
5453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5456         ret_ref = (uint64_t)ret_var.inner;
5457         if (ret_var.is_owned) {
5458                 ret_ref |= 1;
5459         }
5460         return ret_ref;
5461 }
5462
5463 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5464 CHECK(owner->result_ok);
5465         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
5466 }
5467 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5468         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5469         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5470         uint64_t ret_ref = 0;
5471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5474         ret_ref = (uint64_t)ret_var.inner;
5475         if (ret_var.is_owned) {
5476                 ret_ref |= 1;
5477         }
5478         return ret_ref;
5479 }
5480
5481 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5482 CHECK(!owner->result_ok);
5483         return DecodeError_clone(&*owner->contents.err);
5484 }
5485 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5486         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5487         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5488         uint64_t ret_ref = 0;
5489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5492         ret_ref = (uint64_t)ret_var.inner;
5493         if (ret_var.is_owned) {
5494                 ret_ref |= 1;
5495         }
5496         return ret_ref;
5497 }
5498
5499 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5500 CHECK(owner->result_ok);
5501         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5502 }
5503 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5504         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5505         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5506         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5507         uint64_t ret_ref = (uint64_t)ret_copy;
5508         return ret_ref;
5509 }
5510
5511 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5512 CHECK(!owner->result_ok);
5513         return DecodeError_clone(&*owner->contents.err);
5514 }
5515 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5516         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5517         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5518         uint64_t ret_ref = 0;
5519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5522         ret_ref = (uint64_t)ret_var.inner;
5523         if (ret_var.is_owned) {
5524                 ret_ref |= 1;
5525         }
5526         return ret_ref;
5527 }
5528
5529 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5530 CHECK(owner->result_ok);
5531         return Sign_clone(&*owner->contents.result);
5532 }
5533 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
5534         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5535         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5536         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5537         return (uint64_t)ret_ret;
5538 }
5539
5540 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5541 CHECK(!owner->result_ok);
5542         return DecodeError_clone(&*owner->contents.err);
5543 }
5544 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
5545         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5546         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5547         uint64_t ret_ref = 0;
5548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5551         ret_ref = (uint64_t)ret_var.inner;
5552         if (ret_var.is_owned) {
5553                 ret_ref |= 1;
5554         }
5555         return ret_ref;
5556 }
5557
5558 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5559 CHECK(owner->result_ok);
5560         return *owner->contents.result;
5561 }
5562 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
5563         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5564         int8_tArray ret_arr = init_int8_tArray(68);
5565         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
5566         return ret_arr;
5567 }
5568
5569 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5570 CHECK(!owner->result_ok);
5571         return *owner->contents.err;
5572 }
5573 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
5574         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5575         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5576 }
5577
5578 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5579         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5580         for (size_t i = 0; i < ret.datalen; i++) {
5581                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5582         }
5583         return ret;
5584 }
5585 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5586 CHECK(owner->result_ok);
5587         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5588 }
5589 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
5590         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5591         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5592         ptrArray ret_arr = NULL;
5593         ret_arr = init_ptrArray(ret_var.datalen);
5594         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
5595         for (size_t m = 0; m < ret_var.datalen; m++) {
5596                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
5597                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen);
5598                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
5599                 CVec_u8Z_free(ret_conv_12_var);
5600                 ret_arr_ptr[m] = ret_conv_12_arr;
5601         }
5602         
5603         FREE(ret_var.data);
5604         return ret_arr;
5605 }
5606
5607 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5608 CHECK(!owner->result_ok);
5609         return *owner->contents.err;
5610 }
5611 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
5612         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5613         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5614 }
5615
5616 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5617 CHECK(owner->result_ok);
5618         return InMemorySigner_clone(&*owner->contents.result);
5619 }
5620 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
5621         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5622         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5623         uint64_t ret_ref = 0;
5624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5627         ret_ref = (uint64_t)ret_var.inner;
5628         if (ret_var.is_owned) {
5629                 ret_ref |= 1;
5630         }
5631         return ret_ref;
5632 }
5633
5634 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5635 CHECK(!owner->result_ok);
5636         return DecodeError_clone(&*owner->contents.err);
5637 }
5638 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
5639         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5640         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5641         uint64_t ret_ref = 0;
5642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5645         ret_ref = (uint64_t)ret_var.inner;
5646         if (ret_var.is_owned) {
5647                 ret_ref |= 1;
5648         }
5649         return ret_ref;
5650 }
5651
5652 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5653         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5654         for (size_t i = 0; i < ret.datalen; i++) {
5655                 ret.data[i] = TxOut_clone(&orig->data[i]);
5656         }
5657         return ret;
5658 }
5659 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5660 CHECK(owner->result_ok);
5661         return *owner->contents.result;
5662 }
5663 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
5664         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5665         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
5667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5668         return ret_arr;
5669 }
5670
5671 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5672 CHECK(!owner->result_ok);
5673         return *owner->contents.err;
5674 }
5675 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
5676         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5677         CResult_TransactionNoneZ_get_err(owner_conv);
5678 }
5679
5680 typedef struct LDKFilter_JCalls {
5681         atomic_size_t refcnt;
5682         uint32_t instance_ptr;
5683 } LDKFilter_JCalls;
5684 static void LDKFilter_JCalls_free(void* this_arg) {
5685         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5687                 FREE(j_calls);
5688         }
5689 }
5690 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5691         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5692         int8_tArray txid_arr = init_int8_tArray(32);
5693         memcpy(txid_arr->elems, *txid, 32);
5694         LDKu8slice script_pubkey_var = script_pubkey;
5695         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen);
5696         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
5697         js_invoke_function_2(j_calls->instance_ptr, 18, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
5698 }
5699 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5700         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5701         LDKWatchedOutput output_var = output;
5702         uint64_t output_ref = 0;
5703         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5704         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5705         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
5706         output_ref = (uint64_t)output_var.inner;
5707         if (output_var.is_owned) {
5708                 output_ref |= 1;
5709         }
5710         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 19, (uint32_t)output_ref);
5711         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5712         CHECK_ACCESS(ret_ptr);
5713         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5714         FREE((void*)ret);
5715         return ret_conv;
5716 }
5717 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5718         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5719         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5720 }
5721 static inline LDKFilter LDKFilter_init (JSValue o) {
5722         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5723         atomic_init(&calls->refcnt, 1);
5724         calls->instance_ptr = o;
5725
5726         LDKFilter ret = {
5727                 .this_arg = (void*) calls,
5728                 .register_tx = register_tx_LDKFilter_jcall,
5729                 .register_output = register_output_LDKFilter_jcall,
5730                 .free = LDKFilter_JCalls_free,
5731         };
5732         return ret;
5733 }
5734 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
5735         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5736         *res_ptr = LDKFilter_init(o);
5737         return (long)res_ptr;
5738 }
5739 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5740         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5741         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5742         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5743         unsigned char txid_arr[32];
5744         CHECK(txid->arr_len == 32);
5745         memcpy(txid_arr, txid->elems, 32);
5746         unsigned char (*txid_ref)[32] = &txid_arr;
5747         LDKu8slice script_pubkey_ref;
5748         script_pubkey_ref.datalen = script_pubkey->arr_len;
5749         script_pubkey_ref.data = script_pubkey->elems;
5750         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5751 }
5752
5753 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5754         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5756         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5757         LDKWatchedOutput output_conv;
5758         output_conv.inner = (void*)(output & (~1));
5759         output_conv.is_owned = (output & 1) || (output == 0);
5760         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
5761         output_conv = WatchedOutput_clone(&output_conv);
5762         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5763         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5764         uint64_t ret_ref = (uint64_t)ret_copy;
5765         return ret_ref;
5766 }
5767
5768 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
5769         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5770         switch(obj->tag) {
5771                 case LDKCOption_FilterZ_Some: return 0;
5772                 case LDKCOption_FilterZ_None: return 1;
5773                 default: abort();
5774         }
5775 }
5776 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
5777         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5778         assert(obj->tag == LDKCOption_FilterZ_Some);
5779                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5780                         *some_ret = obj->some;
5781                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5782         return (uint64_t)some_ret;
5783 }
5784 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5785 CHECK(owner->result_ok);
5786         return &*owner->contents.result;
5787 }
5788 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
5789         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5790         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
5791         uint64_t ret_ref = 0;
5792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5795         ret_ref = (uint64_t)ret_var.inner & ~1;
5796         return ret_ref;
5797 }
5798
5799 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5800 CHECK(!owner->result_ok);
5801         return *owner->contents.err;
5802 }
5803 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
5804         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5805         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
5806 }
5807
5808 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5809         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5810         for (size_t i = 0; i < ret.datalen; i++) {
5811                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5812         }
5813         return ret;
5814 }
5815 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
5816         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5817         switch(obj->tag) {
5818                 case LDKAPIError_APIMisuseError: return 0;
5819                 case LDKAPIError_FeeRateTooHigh: return 1;
5820                 case LDKAPIError_RouteError: return 2;
5821                 case LDKAPIError_ChannelUnavailable: return 3;
5822                 case LDKAPIError_MonitorUpdateFailed: return 4;
5823                 case LDKAPIError_IncompatibleShutdownScript: return 5;
5824                 default: abort();
5825         }
5826 }
5827 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
5828         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5829         assert(obj->tag == LDKAPIError_APIMisuseError);
5830                         LDKStr err_str = obj->api_misuse_error.err;
5831                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5832         return err_conv;
5833 }
5834 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
5835         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5836         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5837                         LDKStr err_str = obj->fee_rate_too_high.err;
5838                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5839         return err_conv;
5840 }
5841 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
5842         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5843         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5844         return obj->fee_rate_too_high.feerate;
5845 }
5846 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
5847         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5848         assert(obj->tag == LDKAPIError_RouteError);
5849                         LDKStr err_str = obj->route_error.err;
5850                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5851         return err_conv;
5852 }
5853 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
5854         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5855         assert(obj->tag == LDKAPIError_ChannelUnavailable);
5856                         LDKStr err_str = obj->channel_unavailable.err;
5857                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5858         return err_conv;
5859 }
5860 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
5861         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5862         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
5863                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5864                         uint64_t script_ref = 0;
5865                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5866                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5867                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5868                         script_ref = (uint64_t)script_var.inner & ~1;
5869         return script_ref;
5870 }
5871 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5872 CHECK(owner->result_ok);
5873         return *owner->contents.result;
5874 }
5875 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
5876         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5877         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5878 }
5879
5880 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5881 CHECK(!owner->result_ok);
5882         return APIError_clone(&*owner->contents.err);
5883 }
5884 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
5885         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5886         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5887         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5888         uint64_t ret_ref = (uint64_t)ret_copy;
5889         return ret_ref;
5890 }
5891
5892 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
5893         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5894         switch(obj->tag) {
5895                 case LDKCOption_u16Z_Some: return 0;
5896                 case LDKCOption_u16Z_None: return 1;
5897                 default: abort();
5898         }
5899 }
5900 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
5901         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5902         assert(obj->tag == LDKCOption_u16Z_Some);
5903         return obj->some;
5904 }
5905 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5906         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5907         for (size_t i = 0; i < ret.datalen; i++) {
5908                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5909         }
5910         return ret;
5911 }
5912 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5913         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5914         for (size_t i = 0; i < ret.datalen; i++) {
5915                 ret.data[i] = APIError_clone(&orig->data[i]);
5916         }
5917         return ret;
5918 }
5919 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5920 CHECK(owner->result_ok);
5921         return ThirtyTwoBytes_clone(&*owner->contents.result);
5922 }
5923 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
5924         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5925         int8_tArray ret_arr = init_int8_tArray(32);
5926         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
5927         return ret_arr;
5928 }
5929
5930 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5931 CHECK(!owner->result_ok);
5932         return APIError_clone(&*owner->contents.err);
5933 }
5934 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
5935         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5936         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5937         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5938         uint64_t ret_ref = (uint64_t)ret_copy;
5939         return ret_ref;
5940 }
5941
5942 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
5943         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5944         switch(obj->tag) {
5945                 case LDKPaymentSendFailure_ParameterError: return 0;
5946                 case LDKPaymentSendFailure_PathParameterError: return 1;
5947                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
5948                 case LDKPaymentSendFailure_PartialFailure: return 3;
5949                 default: abort();
5950         }
5951 }
5952 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
5953         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5954         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
5955                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
5956         return parameter_error_ref;
5957 }
5958 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
5959         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5960         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
5961                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5962                         uint32_tArray path_parameter_error_arr = NULL;
5963                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen);
5964                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
5965                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5966                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5967                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5968                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5969                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
5970                         }
5971                         
5972         return path_parameter_error_arr;
5973 }
5974 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
5975         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5976         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
5977                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5978                         uint32_tArray all_failed_retry_safe_arr = NULL;
5979                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen);
5980                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
5981                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5982                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
5983                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5984                         }
5985                         
5986         return all_failed_retry_safe_arr;
5987 }
5988 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
5989         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5990         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
5991                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5992                         uint32_tArray results_arr = NULL;
5993                         results_arr = init_uint32_tArray(results_var.datalen);
5994                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
5995                         for (size_t w = 0; w < results_var.datalen; w++) {
5996                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5997                                 *results_conv_22_conv = results_var.data[w];
5998                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5999                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
6000                         }
6001                         
6002         return results_arr;
6003 }
6004 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
6005         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6006         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6007                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6008                         uint64_t failed_paths_retry_ref = 0;
6009                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
6010                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6011                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6012                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6013                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
6014                         }
6015         return failed_paths_retry_ref;
6016 }
6017 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
6018         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6019         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6020                         int8_tArray payment_id_arr = init_int8_tArray(32);
6021                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
6022         return payment_id_arr;
6023 }
6024 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6025 CHECK(owner->result_ok);
6026         return ThirtyTwoBytes_clone(&*owner->contents.result);
6027 }
6028 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
6029         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6030         int8_tArray ret_arr = init_int8_tArray(32);
6031         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
6032         return ret_arr;
6033 }
6034
6035 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6036 CHECK(!owner->result_ok);
6037         return PaymentSendFailure_clone(&*owner->contents.err);
6038 }
6039 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
6040         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6041         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6042         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6043         uint64_t ret_ref = (uint64_t)ret_copy;
6044         return ret_ref;
6045 }
6046
6047 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6048 CHECK(owner->result_ok);
6049         return *owner->contents.result;
6050 }
6051 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
6052         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6053         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6054 }
6055
6056 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6057 CHECK(!owner->result_ok);
6058         return PaymentSendFailure_clone(&*owner->contents.err);
6059 }
6060 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
6061         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6062         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6063         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6064         uint64_t ret_ref = (uint64_t)ret_copy;
6065         return ret_ref;
6066 }
6067
6068 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6069         return ThirtyTwoBytes_clone(&owner->a);
6070 }
6071 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
6072         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6073         int8_tArray ret_arr = init_int8_tArray(32);
6074         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
6075         return ret_arr;
6076 }
6077
6078 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6079         return ThirtyTwoBytes_clone(&owner->b);
6080 }
6081 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
6082         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6083         int8_tArray ret_arr = init_int8_tArray(32);
6084         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
6085         return ret_arr;
6086 }
6087
6088 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6089 CHECK(owner->result_ok);
6090         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6091 }
6092 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
6093         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6094         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6095         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6096         return ((uint64_t)ret_conv);
6097 }
6098
6099 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6100 CHECK(!owner->result_ok);
6101         return PaymentSendFailure_clone(&*owner->contents.err);
6102 }
6103 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
6104         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6105         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6106         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6107         uint64_t ret_ref = (uint64_t)ret_copy;
6108         return ret_ref;
6109 }
6110
6111 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6112         return ThirtyTwoBytes_clone(&owner->a);
6113 }
6114 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
6115         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6116         int8_tArray ret_arr = init_int8_tArray(32);
6117         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
6118         return ret_arr;
6119 }
6120
6121 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6122         return ThirtyTwoBytes_clone(&owner->b);
6123 }
6124 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
6125         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6126         int8_tArray ret_arr = init_int8_tArray(32);
6127         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
6128         return ret_arr;
6129 }
6130
6131 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6132 CHECK(owner->result_ok);
6133         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6134 }
6135 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
6136         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6137         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6138         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6139         return ((uint64_t)ret_conv);
6140 }
6141
6142 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6143 CHECK(!owner->result_ok);
6144         return *owner->contents.err;
6145 }
6146 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
6147         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6148         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6149 }
6150
6151 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6152 CHECK(owner->result_ok);
6153         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6154 }
6155 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
6156         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6157         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6158         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6159         return ((uint64_t)ret_conv);
6160 }
6161
6162 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6163 CHECK(!owner->result_ok);
6164         return APIError_clone(&*owner->contents.err);
6165 }
6166 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
6167         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6168         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6169         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6170         uint64_t ret_ref = (uint64_t)ret_copy;
6171         return ret_ref;
6172 }
6173
6174 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6175 CHECK(owner->result_ok);
6176         return ThirtyTwoBytes_clone(&*owner->contents.result);
6177 }
6178 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
6179         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6180         int8_tArray ret_arr = init_int8_tArray(32);
6181         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
6182         return ret_arr;
6183 }
6184
6185 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6186 CHECK(!owner->result_ok);
6187         return *owner->contents.err;
6188 }
6189 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
6190         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6191         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6192 }
6193
6194 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6195 CHECK(owner->result_ok);
6196         return ThirtyTwoBytes_clone(&*owner->contents.result);
6197 }
6198 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
6199         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6200         int8_tArray ret_arr = init_int8_tArray(32);
6201         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
6202         return ret_arr;
6203 }
6204
6205 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6206 CHECK(!owner->result_ok);
6207         return APIError_clone(&*owner->contents.err);
6208 }
6209 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
6210         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6211         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6212         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6213         uint64_t ret_ref = (uint64_t)ret_copy;
6214         return ret_ref;
6215 }
6216
6217 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6218 CHECK(owner->result_ok);
6219         return ThirtyTwoBytes_clone(&*owner->contents.result);
6220 }
6221 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
6222         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6223         int8_tArray ret_arr = init_int8_tArray(32);
6224         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
6225         return ret_arr;
6226 }
6227
6228 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6229 CHECK(!owner->result_ok);
6230         return APIError_clone(&*owner->contents.err);
6231 }
6232 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
6233         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6234         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6235         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6236         uint64_t ret_ref = (uint64_t)ret_copy;
6237         return ret_ref;
6238 }
6239
6240 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6241         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6242         for (size_t i = 0; i < ret.datalen; i++) {
6243                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6244         }
6245         return ret;
6246 }
6247 typedef struct LDKWatch_JCalls {
6248         atomic_size_t refcnt;
6249         uint32_t instance_ptr;
6250 } LDKWatch_JCalls;
6251 static void LDKWatch_JCalls_free(void* this_arg) {
6252         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6253         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6254                 FREE(j_calls);
6255         }
6256 }
6257 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6258         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6259         LDKOutPoint funding_txo_var = funding_txo;
6260         uint64_t funding_txo_ref = 0;
6261         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6262         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6263         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6264         funding_txo_ref = (uint64_t)funding_txo_var.inner;
6265         if (funding_txo_var.is_owned) {
6266                 funding_txo_ref |= 1;
6267         }
6268         LDKChannelMonitor monitor_var = monitor;
6269         uint64_t monitor_ref = 0;
6270         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6271         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6272         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6273         monitor_ref = (uint64_t)monitor_var.inner;
6274         if (monitor_var.is_owned) {
6275                 monitor_ref |= 1;
6276         }
6277         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 20, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
6278         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6279         CHECK_ACCESS(ret_ptr);
6280         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6281         FREE((void*)ret);
6282         return ret_conv;
6283 }
6284 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6285         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6286         LDKOutPoint funding_txo_var = funding_txo;
6287         uint64_t funding_txo_ref = 0;
6288         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6289         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6290         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6291         funding_txo_ref = (uint64_t)funding_txo_var.inner;
6292         if (funding_txo_var.is_owned) {
6293                 funding_txo_ref |= 1;
6294         }
6295         LDKChannelMonitorUpdate update_var = update;
6296         uint64_t update_ref = 0;
6297         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6298         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6299         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6300         update_ref = (uint64_t)update_var.inner;
6301         if (update_var.is_owned) {
6302                 update_ref |= 1;
6303         }
6304         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
6305         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6306         CHECK_ACCESS(ret_ptr);
6307         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6308         FREE((void*)ret);
6309         return ret_conv;
6310 }
6311 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6312         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6313         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
6314         LDKCVec_MonitorEventZ ret_constr;
6315         ret_constr.datalen = ret->arr_len;
6316         if (ret_constr.datalen > 0)
6317                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6318         else
6319                 ret_constr.data = NULL;
6320         uint32_t* ret_vals = ret->elems;
6321         for (size_t o = 0; o < ret_constr.datalen; o++) {
6322                 uint32_t ret_conv_14 = ret_vals[o];
6323                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
6324                 CHECK_ACCESS(ret_conv_14_ptr);
6325                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
6326                 FREE((void*)ret_conv_14);
6327                 ret_constr.data[o] = ret_conv_14_conv;
6328         }
6329         return ret_constr;
6330 }
6331 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6332         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6333         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6334 }
6335 static inline LDKWatch LDKWatch_init (JSValue o) {
6336         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6337         atomic_init(&calls->refcnt, 1);
6338         calls->instance_ptr = o;
6339
6340         LDKWatch ret = {
6341                 .this_arg = (void*) calls,
6342                 .watch_channel = watch_channel_LDKWatch_jcall,
6343                 .update_channel = update_channel_LDKWatch_jcall,
6344                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6345                 .free = LDKWatch_JCalls_free,
6346         };
6347         return ret;
6348 }
6349 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
6350         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6351         *res_ptr = LDKWatch_init(o);
6352         return (long)res_ptr;
6353 }
6354 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
6355         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6356         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6357         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6358         LDKOutPoint funding_txo_conv;
6359         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6360         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6361         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6362         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6363         LDKChannelMonitor monitor_conv;
6364         monitor_conv.inner = (void*)(monitor & (~1));
6365         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6366         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6367         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6368         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6369         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6370         return (uint64_t)ret_conv;
6371 }
6372
6373 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
6374         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6375         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6376         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6377         LDKOutPoint funding_txo_conv;
6378         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6379         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6380         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6381         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6382         LDKChannelMonitorUpdate update_conv;
6383         update_conv.inner = (void*)(update & (~1));
6384         update_conv.is_owned = (update & 1) || (update == 0);
6385         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6386         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6387         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6388         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6389         return (uint64_t)ret_conv;
6390 }
6391
6392 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
6393         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6395         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6396         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6397         uint32_tArray ret_arr = NULL;
6398         ret_arr = init_uint32_tArray(ret_var.datalen);
6399         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6400         for (size_t o = 0; o < ret_var.datalen; o++) {
6401                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
6402                 *ret_conv_14_copy = ret_var.data[o];
6403                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
6404                 ret_arr_ptr[o] = ret_conv_14_ref;
6405         }
6406         
6407         FREE(ret_var.data);
6408         return ret_arr;
6409 }
6410
6411 typedef struct LDKBroadcasterInterface_JCalls {
6412         atomic_size_t refcnt;
6413         uint32_t instance_ptr;
6414 } LDKBroadcasterInterface_JCalls;
6415 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6416         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6417         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6418                 FREE(j_calls);
6419         }
6420 }
6421 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6422         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6423         LDKTransaction tx_var = tx;
6424         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen);
6425         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
6426         Transaction_free(tx_var);
6427         js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)tx_arr);
6428 }
6429 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6430         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6431         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6432 }
6433 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
6434         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6435         atomic_init(&calls->refcnt, 1);
6436         calls->instance_ptr = o;
6437
6438         LDKBroadcasterInterface ret = {
6439                 .this_arg = (void*) calls,
6440                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6441                 .free = LDKBroadcasterInterface_JCalls_free,
6442         };
6443         return ret;
6444 }
6445 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
6446         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6447         *res_ptr = LDKBroadcasterInterface_init(o);
6448         return (long)res_ptr;
6449 }
6450 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
6451         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6452         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6453         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6454         LDKTransaction tx_ref;
6455         tx_ref.datalen = tx->arr_len;
6456         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6457         memcpy(tx_ref.data, tx->elems, tx_ref.datalen);
6458         tx_ref.data_is_owned = true;
6459         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6460 }
6461
6462 typedef struct LDKKeysInterface_JCalls {
6463         atomic_size_t refcnt;
6464         uint32_t instance_ptr;
6465 } LDKKeysInterface_JCalls;
6466 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6467         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6468         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6469                 FREE(j_calls);
6470         }
6471 }
6472 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
6473         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6474         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 24);
6475         LDKSecretKey ret_ref;
6476         CHECK(ret->arr_len == 32);
6477         memcpy(ret_ref.bytes, ret->elems, 32);
6478         return ret_ref;
6479 }
6480 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6481         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6482         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
6483         LDKCVec_u8Z ret_ref;
6484         ret_ref.datalen = ret->arr_len;
6485         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6486         memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
6487         return ret_ref;
6488 }
6489 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6490         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6491         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 26);
6492         LDKShutdownScript ret_conv;
6493         ret_conv.inner = (void*)(ret & (~1));
6494         ret_conv.is_owned = (ret & 1) || (ret == 0);
6495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6496         return ret_conv;
6497 }
6498 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6499         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6500         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 27, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
6501         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6502         CHECK_ACCESS(ret_ptr);
6503         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6504         FREE((void*)ret);
6505         return ret_conv;
6506 }
6507 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6508         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6509         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 28);
6510         LDKThirtyTwoBytes ret_ref;
6511         CHECK(ret->arr_len == 32);
6512         memcpy(ret_ref.data, ret->elems, 32);
6513         return ret_ref;
6514 }
6515 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6516         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6517         LDKu8slice reader_var = reader;
6518         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen);
6519         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
6520         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 29, (uint32_t)reader_arr);
6521         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6522         CHECK_ACCESS(ret_ptr);
6523         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6524         FREE((void*)ret);
6525         return ret_conv;
6526 }
6527 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
6528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6529         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
6530         int8_tArray invoice_preimage_arr = init_int8_tArray(invoice_preimage_var.datalen);
6531         memcpy(invoice_preimage_arr->elems, invoice_preimage_var.data, invoice_preimage_var.datalen);
6532         CVec_u8Z_free(invoice_preimage_var);
6533         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 30, (uint32_t)invoice_preimage_arr);
6534         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6535         CHECK_ACCESS(ret_ptr);
6536         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6537         FREE((void*)ret);
6538         return ret_conv;
6539 }
6540 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6541         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6542         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 31);
6543         LDKThirtyTwoBytes ret_ref;
6544         CHECK(ret->arr_len == 32);
6545         memcpy(ret_ref.data, ret->elems, 32);
6546         return ret_ref;
6547 }
6548 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6549         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6550         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6551 }
6552 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
6553         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6554         atomic_init(&calls->refcnt, 1);
6555         calls->instance_ptr = o;
6556
6557         LDKKeysInterface ret = {
6558                 .this_arg = (void*) calls,
6559                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6560                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6561                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6562                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6563                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6564                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6565                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6566                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6567                 .free = LDKKeysInterface_JCalls_free,
6568         };
6569         return ret;
6570 }
6571 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
6572         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6573         *res_ptr = LDKKeysInterface_init(o);
6574         return (long)res_ptr;
6575 }
6576 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
6577         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6578         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6579         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6580         int8_tArray ret_arr = init_int8_tArray(32);
6581         memcpy(ret_arr->elems, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
6582         return ret_arr;
6583 }
6584
6585 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
6586         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6587         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6588         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6589         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6590         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
6591         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6592         CVec_u8Z_free(ret_var);
6593         return ret_arr;
6594 }
6595
6596 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
6597         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6598         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6599         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6600         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6601         uint64_t ret_ref = 0;
6602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6605         ret_ref = (uint64_t)ret_var.inner;
6606         if (ret_var.is_owned) {
6607                 ret_ref |= 1;
6608         }
6609         return ret_ref;
6610 }
6611
6612 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) {
6613         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6614         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6615         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6616         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6617         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6618         return (uint64_t)ret_ret;
6619 }
6620
6621 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
6622         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6625         int8_tArray ret_arr = init_int8_tArray(32);
6626         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
6627         return ret_arr;
6628 }
6629
6630 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
6631         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6632         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6633         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6634         LDKu8slice reader_ref;
6635         reader_ref.datalen = reader->arr_len;
6636         reader_ref.data = reader->elems;
6637         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6638         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6639         return (uint64_t)ret_conv;
6640 }
6641
6642 uint32_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
6643         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6644         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6645         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6646         LDKCVec_u8Z invoice_preimage_ref;
6647         invoice_preimage_ref.datalen = invoice_preimage->arr_len;
6648         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
6649         memcpy(invoice_preimage_ref.data, invoice_preimage->elems, invoice_preimage_ref.datalen);
6650         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6651         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
6652         return (uint64_t)ret_conv;
6653 }
6654
6655 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
6656         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6657         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6658         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6659         int8_tArray ret_arr = init_int8_tArray(32);
6660         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
6661         return ret_arr;
6662 }
6663
6664 typedef struct LDKFeeEstimator_JCalls {
6665         atomic_size_t refcnt;
6666         uint32_t instance_ptr;
6667 } LDKFeeEstimator_JCalls;
6668 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6669         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6670         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6671                 FREE(j_calls);
6672         }
6673 }
6674 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6675         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6676         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
6677         return js_invoke_function_1(j_calls->instance_ptr, 32, (uint32_t)confirmation_target_conv);
6678 }
6679 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6680         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6681         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6682 }
6683 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
6684         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6685         atomic_init(&calls->refcnt, 1);
6686         calls->instance_ptr = o;
6687
6688         LDKFeeEstimator ret = {
6689                 .this_arg = (void*) calls,
6690                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6691                 .free = LDKFeeEstimator_JCalls_free,
6692         };
6693         return ret;
6694 }
6695 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
6696         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6697         *res_ptr = LDKFeeEstimator_init(o);
6698         return (long)res_ptr;
6699 }
6700 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) {
6701         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6702         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6703         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6704         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
6705         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6706         return ret_val;
6707 }
6708
6709 typedef struct LDKLogger_JCalls {
6710         atomic_size_t refcnt;
6711         uint32_t instance_ptr;
6712 } LDKLogger_JCalls;
6713 static void LDKLogger_JCalls_free(void* this_arg) {
6714         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6715         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6716                 FREE(j_calls);
6717         }
6718 }
6719 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6720         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6721         LDKRecord record_var = *record;
6722         uint64_t record_ref = 0;
6723         record_var = Record_clone(record);
6724         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6725         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6726         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6727         record_ref = (uint64_t)record_var.inner;
6728         if (record_var.is_owned) {
6729                 record_ref |= 1;
6730         }
6731         js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)record_ref);
6732 }
6733 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6734         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6735         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6736 }
6737 static inline LDKLogger LDKLogger_init (JSValue o) {
6738         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6739         atomic_init(&calls->refcnt, 1);
6740         calls->instance_ptr = o;
6741
6742         LDKLogger ret = {
6743                 .this_arg = (void*) calls,
6744                 .log = log_LDKLogger_jcall,
6745                 .free = LDKLogger_JCalls_free,
6746         };
6747         return ret;
6748 }
6749 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
6750         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6751         *res_ptr = LDKLogger_init(o);
6752         return (long)res_ptr;
6753 }
6754 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6755         return ThirtyTwoBytes_clone(&owner->a);
6756 }
6757 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
6758         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6759         int8_tArray ret_arr = init_int8_tArray(32);
6760         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
6761         return ret_arr;
6762 }
6763
6764 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6765         return &owner->b;
6766 }
6767 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
6768         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6769         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6770         uint64_t ret_ref = 0;
6771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6774         ret_ref = (uint64_t)ret_var.inner & ~1;
6775         return ret_ref;
6776 }
6777
6778 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6779 CHECK(owner->result_ok);
6780         return &*owner->contents.result;
6781 }
6782 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
6783         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6784         uint64_t ret_ret = (uint64_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6785         return ret_ret;
6786 }
6787
6788 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6789 CHECK(!owner->result_ok);
6790         return DecodeError_clone(&*owner->contents.err);
6791 }
6792 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
6793         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6794         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6795         uint64_t ret_ref = 0;
6796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6799         ret_ref = (uint64_t)ret_var.inner;
6800         if (ret_var.is_owned) {
6801                 ret_ref |= 1;
6802         }
6803         return ret_ref;
6804 }
6805
6806 typedef struct LDKMessageSendEventsProvider_JCalls {
6807         atomic_size_t refcnt;
6808         uint32_t instance_ptr;
6809 } LDKMessageSendEventsProvider_JCalls;
6810 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6811         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6812         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6813                 FREE(j_calls);
6814         }
6815 }
6816 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6817         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6818         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
6819         LDKCVec_MessageSendEventZ ret_constr;
6820         ret_constr.datalen = ret->arr_len;
6821         if (ret_constr.datalen > 0)
6822                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6823         else
6824                 ret_constr.data = NULL;
6825         uint32_t* ret_vals = ret->elems;
6826         for (size_t s = 0; s < ret_constr.datalen; s++) {
6827                 uint32_t ret_conv_18 = ret_vals[s];
6828                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
6829                 CHECK_ACCESS(ret_conv_18_ptr);
6830                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
6831                 FREE((void*)ret_conv_18);
6832                 ret_constr.data[s] = ret_conv_18_conv;
6833         }
6834         return ret_constr;
6835 }
6836 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6837         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6838         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6839 }
6840 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
6841         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6842         atomic_init(&calls->refcnt, 1);
6843         calls->instance_ptr = o;
6844
6845         LDKMessageSendEventsProvider ret = {
6846                 .this_arg = (void*) calls,
6847                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6848                 .free = LDKMessageSendEventsProvider_JCalls_free,
6849         };
6850         return ret;
6851 }
6852 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
6853         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6854         *res_ptr = LDKMessageSendEventsProvider_init(o);
6855         return (long)res_ptr;
6856 }
6857 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) {
6858         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6859         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6860         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
6861         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6862         uint32_tArray ret_arr = NULL;
6863         ret_arr = init_uint32_tArray(ret_var.datalen);
6864         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6865         for (size_t s = 0; s < ret_var.datalen; s++) {
6866                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6867                 *ret_conv_18_copy = ret_var.data[s];
6868                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6869                 ret_arr_ptr[s] = ret_conv_18_ref;
6870         }
6871         
6872         FREE(ret_var.data);
6873         return ret_arr;
6874 }
6875
6876 typedef struct LDKEventHandler_JCalls {
6877         atomic_size_t refcnt;
6878         uint32_t instance_ptr;
6879 } LDKEventHandler_JCalls;
6880 static void LDKEventHandler_JCalls_free(void* this_arg) {
6881         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6882         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6883                 FREE(j_calls);
6884         }
6885 }
6886 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
6887         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6888         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
6889         *ret_event = Event_clone(event);
6890         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint64_t)ret_event);
6891 }
6892 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6893         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6894         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6895 }
6896 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
6897         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6898         atomic_init(&calls->refcnt, 1);
6899         calls->instance_ptr = o;
6900
6901         LDKEventHandler ret = {
6902                 .this_arg = (void*) calls,
6903                 .handle_event = handle_event_LDKEventHandler_jcall,
6904                 .free = LDKEventHandler_JCalls_free,
6905         };
6906         return ret;
6907 }
6908 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
6909         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6910         *res_ptr = LDKEventHandler_init(o);
6911         return (long)res_ptr;
6912 }
6913 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
6914         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6915         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6916         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
6917         LDKEvent* event_conv = (LDKEvent*)event;
6918         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6919 }
6920
6921 typedef struct LDKEventsProvider_JCalls {
6922         atomic_size_t refcnt;
6923         uint32_t instance_ptr;
6924 } LDKEventsProvider_JCalls;
6925 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6926         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6927         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6928                 FREE(j_calls);
6929         }
6930 }
6931 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6932         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6933         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6934         *handler_ret = handler;
6935         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint64_t)handler_ret);
6936 }
6937 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6938         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6939         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6940 }
6941 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
6942         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6943         atomic_init(&calls->refcnt, 1);
6944         calls->instance_ptr = o;
6945
6946         LDKEventsProvider ret = {
6947                 .this_arg = (void*) calls,
6948                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6949                 .free = LDKEventsProvider_JCalls_free,
6950         };
6951         return ret;
6952 }
6953 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
6954         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6955         *res_ptr = LDKEventsProvider_init(o);
6956         return (long)res_ptr;
6957 }
6958 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
6959         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6960         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6961         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
6962         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
6963         CHECK_ACCESS(handler_ptr);
6964         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
6965         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6966 }
6967
6968 typedef struct LDKListen_JCalls {
6969         atomic_size_t refcnt;
6970         uint32_t instance_ptr;
6971 } LDKListen_JCalls;
6972 static void LDKListen_JCalls_free(void* this_arg) {
6973         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6974         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6975                 FREE(j_calls);
6976         }
6977 }
6978 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6979         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6980         LDKu8slice block_var = block;
6981         int8_tArray block_arr = init_int8_tArray(block_var.datalen);
6982         memcpy(block_arr->elems, block_var.data, block_var.datalen);
6983         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
6984 }
6985 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6986         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6987         int8_tArray header_arr = init_int8_tArray(80);
6988         memcpy(header_arr->elems, *header, 80);
6989         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
6990 }
6991 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6992         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6993         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6994 }
6995 static inline LDKListen LDKListen_init (JSValue o) {
6996         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6997         atomic_init(&calls->refcnt, 1);
6998         calls->instance_ptr = o;
6999
7000         LDKListen ret = {
7001                 .this_arg = (void*) calls,
7002                 .block_connected = block_connected_LDKListen_jcall,
7003                 .block_disconnected = block_disconnected_LDKListen_jcall,
7004                 .free = LDKListen_JCalls_free,
7005         };
7006         return ret;
7007 }
7008 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
7009         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7010         *res_ptr = LDKListen_init(o);
7011         return (long)res_ptr;
7012 }
7013 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
7014         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7016         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7017         LDKu8slice block_ref;
7018         block_ref.datalen = block->arr_len;
7019         block_ref.data = block->elems;
7020         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7021 }
7022
7023 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
7024         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7025         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7026         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7027         unsigned char header_arr[80];
7028         CHECK(header->arr_len == 80);
7029         memcpy(header_arr, header->elems, 80);
7030         unsigned char (*header_ref)[80] = &header_arr;
7031         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7032 }
7033
7034 typedef struct LDKConfirm_JCalls {
7035         atomic_size_t refcnt;
7036         uint32_t instance_ptr;
7037 } LDKConfirm_JCalls;
7038 static void LDKConfirm_JCalls_free(void* this_arg) {
7039         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7040         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7041                 FREE(j_calls);
7042         }
7043 }
7044 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7045         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7046         int8_tArray header_arr = init_int8_tArray(80);
7047         memcpy(header_arr->elems, *header, 80);
7048         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7049         uint32_tArray txdata_arr = NULL;
7050         txdata_arr = init_uint32_tArray(txdata_var.datalen);
7051         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
7052         for (size_t c = 0; c < txdata_var.datalen; c++) {
7053                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7054                 *txdata_conv_28_conv = txdata_var.data[c];
7055                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7056         }
7057         
7058         FREE(txdata_var.data);
7059         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
7060 }
7061 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7062         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7063         int8_tArray txid_arr = init_int8_tArray(32);
7064         memcpy(txid_arr->elems, *txid, 32);
7065         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
7066 }
7067 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7068         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7069         int8_tArray header_arr = init_int8_tArray(80);
7070         memcpy(header_arr->elems, *header, 80);
7071         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
7072 }
7073 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7074         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7075         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
7076         LDKCVec_TxidZ ret_constr;
7077         ret_constr.datalen = ret->arr_len;
7078         if (ret_constr.datalen > 0)
7079                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7080         else
7081                 ret_constr.data = NULL;
7082         int8_tArray* ret_vals = (void*) ret->elems;
7083         for (size_t m = 0; m < ret_constr.datalen; m++) {
7084                 int8_tArray ret_conv_12 = ret_vals[m];
7085                 LDKThirtyTwoBytes ret_conv_12_ref;
7086                 CHECK(ret_conv_12->arr_len == 32);
7087                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32);
7088                 ret_constr.data[m] = ret_conv_12_ref;
7089         }
7090         return ret_constr;
7091 }
7092 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7093         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7094         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7095 }
7096 static inline LDKConfirm LDKConfirm_init (JSValue o) {
7097         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7098         atomic_init(&calls->refcnt, 1);
7099         calls->instance_ptr = o;
7100
7101         LDKConfirm ret = {
7102                 .this_arg = (void*) calls,
7103                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7104                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7105                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7106                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7107                 .free = LDKConfirm_JCalls_free,
7108         };
7109         return ret;
7110 }
7111 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
7112         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7113         *res_ptr = LDKConfirm_init(o);
7114         return (long)res_ptr;
7115 }
7116 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) {
7117         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7118         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7119         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7120         unsigned char header_arr[80];
7121         CHECK(header->arr_len == 80);
7122         memcpy(header_arr, header->elems, 80);
7123         unsigned char (*header_ref)[80] = &header_arr;
7124         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7125         txdata_constr.datalen = txdata->arr_len;
7126         if (txdata_constr.datalen > 0)
7127                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7128         else
7129                 txdata_constr.data = NULL;
7130         uint32_t* txdata_vals = txdata->elems;
7131         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7132                 uint32_t txdata_conv_28 = txdata_vals[c];
7133                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
7134                 CHECK_ACCESS(txdata_conv_28_ptr);
7135                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7136                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
7137                 txdata_constr.data[c] = txdata_conv_28_conv;
7138         }
7139         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7140 }
7141
7142 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
7143         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7145         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7146         unsigned char txid_arr[32];
7147         CHECK(txid->arr_len == 32);
7148         memcpy(txid_arr, txid->elems, 32);
7149         unsigned char (*txid_ref)[32] = &txid_arr;
7150         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7151 }
7152
7153 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
7154         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7155         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7156         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7157         unsigned char header_arr[80];
7158         CHECK(header->arr_len == 80);
7159         memcpy(header_arr, header->elems, 80);
7160         unsigned char (*header_ref)[80] = &header_arr;
7161         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7162 }
7163
7164 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
7165         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7167         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7168         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7169         ptrArray ret_arr = NULL;
7170         ret_arr = init_ptrArray(ret_var.datalen);
7171         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
7172         for (size_t m = 0; m < ret_var.datalen; m++) {
7173                 int8_tArray ret_conv_12_arr = init_int8_tArray(32);
7174                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
7175                 ret_arr_ptr[m] = ret_conv_12_arr;
7176         }
7177         
7178         FREE(ret_var.data);
7179         return ret_arr;
7180 }
7181
7182 typedef struct LDKPersist_JCalls {
7183         atomic_size_t refcnt;
7184         uint32_t instance_ptr;
7185 } LDKPersist_JCalls;
7186 static void LDKPersist_JCalls_free(void* this_arg) {
7187         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7188         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7189                 FREE(j_calls);
7190         }
7191 }
7192 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7193         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7194         LDKOutPoint channel_id_var = channel_id;
7195         uint64_t channel_id_ref = 0;
7196         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7197         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7198         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7199         channel_id_ref = (uint64_t)channel_id_var.inner;
7200         if (channel_id_var.is_owned) {
7201                 channel_id_ref |= 1;
7202         }
7203         LDKChannelMonitor data_var = *data;
7204         uint64_t data_ref = 0;
7205         data_var = ChannelMonitor_clone(data);
7206         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7207         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7208         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7209         data_ref = (uint64_t)data_var.inner;
7210         if (data_var.is_owned) {
7211                 data_ref |= 1;
7212         }
7213         LDKMonitorUpdateId update_id_var = update_id;
7214         uint64_t update_id_ref = 0;
7215         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7216         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7217         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7218         update_id_ref = (uint64_t)update_id_var.inner;
7219         if (update_id_var.is_owned) {
7220                 update_id_ref |= 1;
7221         }
7222         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);
7223         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7224         CHECK_ACCESS(ret_ptr);
7225         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7226         FREE((void*)ret);
7227         return ret_conv;
7228 }
7229 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7230         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7231         LDKOutPoint channel_id_var = channel_id;
7232         uint64_t channel_id_ref = 0;
7233         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7234         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7235         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7236         channel_id_ref = (uint64_t)channel_id_var.inner;
7237         if (channel_id_var.is_owned) {
7238                 channel_id_ref |= 1;
7239         }
7240         LDKChannelMonitorUpdate update_var = *update;
7241         uint64_t update_ref = 0;
7242         if ((uint64_t)update_var.inner > 4096) {
7243                 update_var = ChannelMonitorUpdate_clone(update);
7244                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7245                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7246         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7247                 update_ref = (uint64_t)update_var.inner;
7248                 if (update_var.is_owned) {
7249                         update_ref |= 1;
7250                 }
7251         }
7252         LDKChannelMonitor data_var = *data;
7253         uint64_t data_ref = 0;
7254         data_var = ChannelMonitor_clone(data);
7255         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7256         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7257         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7258         data_ref = (uint64_t)data_var.inner;
7259         if (data_var.is_owned) {
7260                 data_ref |= 1;
7261         }
7262         LDKMonitorUpdateId update_id_var = update_id;
7263         uint64_t update_id_ref = 0;
7264         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7265         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7266         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7267         update_id_ref = (uint64_t)update_id_var.inner;
7268         if (update_id_var.is_owned) {
7269                 update_id_ref |= 1;
7270         }
7271         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);
7272         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7273         CHECK_ACCESS(ret_ptr);
7274         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7275         FREE((void*)ret);
7276         return ret_conv;
7277 }
7278 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7279         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7280         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7281 }
7282 static inline LDKPersist LDKPersist_init (JSValue o) {
7283         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7284         atomic_init(&calls->refcnt, 1);
7285         calls->instance_ptr = o;
7286
7287         LDKPersist ret = {
7288                 .this_arg = (void*) calls,
7289                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7290                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7291                 .free = LDKPersist_JCalls_free,
7292         };
7293         return ret;
7294 }
7295 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
7296         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7297         *res_ptr = LDKPersist_init(o);
7298         return (long)res_ptr;
7299 }
7300 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) {
7301         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7302         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7303         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7304         LDKOutPoint channel_id_conv;
7305         channel_id_conv.inner = (void*)(channel_id & (~1));
7306         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7307         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7308         channel_id_conv = OutPoint_clone(&channel_id_conv);
7309         LDKChannelMonitor data_conv;
7310         data_conv.inner = (void*)(data & (~1));
7311         data_conv.is_owned = false;
7312         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7313         LDKMonitorUpdateId update_id_conv;
7314         update_id_conv.inner = (void*)(update_id & (~1));
7315         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7316         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7317         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7318         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7319         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
7320         return (uint64_t)ret_conv;
7321 }
7322
7323 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) {
7324         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7325         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7326         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7327         LDKOutPoint channel_id_conv;
7328         channel_id_conv.inner = (void*)(channel_id & (~1));
7329         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7330         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7331         channel_id_conv = OutPoint_clone(&channel_id_conv);
7332         LDKChannelMonitorUpdate update_conv;
7333         update_conv.inner = (void*)(update & (~1));
7334         update_conv.is_owned = false;
7335         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7336         LDKChannelMonitor data_conv;
7337         data_conv.inner = (void*)(data & (~1));
7338         data_conv.is_owned = false;
7339         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7340         LDKMonitorUpdateId update_id_conv;
7341         update_id_conv.inner = (void*)(update_id & (~1));
7342         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7343         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7344         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7345         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7346         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
7347         return (uint64_t)ret_conv;
7348 }
7349
7350 typedef struct LDKChannelMessageHandler_JCalls {
7351         atomic_size_t refcnt;
7352         uint32_t instance_ptr;
7353         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7354 } LDKChannelMessageHandler_JCalls;
7355 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7356         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7357         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7358                 FREE(j_calls);
7359         }
7360 }
7361 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7362         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7363         int8_tArray their_node_id_arr = init_int8_tArray(33);
7364         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7365         LDKInitFeatures their_features_var = their_features;
7366         uint64_t their_features_ref = 0;
7367         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7368         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7369         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7370         their_features_ref = (uint64_t)their_features_var.inner;
7371         if (their_features_var.is_owned) {
7372                 their_features_ref |= 1;
7373         }
7374         LDKOpenChannel msg_var = *msg;
7375         uint64_t msg_ref = 0;
7376         msg_var = OpenChannel_clone(msg);
7377         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7378         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7379         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7380         msg_ref = (uint64_t)msg_var.inner;
7381         if (msg_var.is_owned) {
7382                 msg_ref |= 1;
7383         }
7384         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7385 }
7386 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7387         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7388         int8_tArray their_node_id_arr = init_int8_tArray(33);
7389         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7390         LDKInitFeatures their_features_var = their_features;
7391         uint64_t their_features_ref = 0;
7392         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7393         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7394         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7395         their_features_ref = (uint64_t)their_features_var.inner;
7396         if (their_features_var.is_owned) {
7397                 their_features_ref |= 1;
7398         }
7399         LDKAcceptChannel msg_var = *msg;
7400         uint64_t msg_ref = 0;
7401         msg_var = AcceptChannel_clone(msg);
7402         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7403         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7404         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7405         msg_ref = (uint64_t)msg_var.inner;
7406         if (msg_var.is_owned) {
7407                 msg_ref |= 1;
7408         }
7409         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7410 }
7411 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7412         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7413         int8_tArray their_node_id_arr = init_int8_tArray(33);
7414         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7415         LDKFundingCreated msg_var = *msg;
7416         uint64_t msg_ref = 0;
7417         msg_var = FundingCreated_clone(msg);
7418         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7419         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7420         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7421         msg_ref = (uint64_t)msg_var.inner;
7422         if (msg_var.is_owned) {
7423                 msg_ref |= 1;
7424         }
7425         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7426 }
7427 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7428         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7429         int8_tArray their_node_id_arr = init_int8_tArray(33);
7430         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7431         LDKFundingSigned msg_var = *msg;
7432         uint64_t msg_ref = 0;
7433         msg_var = FundingSigned_clone(msg);
7434         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7435         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7437         msg_ref = (uint64_t)msg_var.inner;
7438         if (msg_var.is_owned) {
7439                 msg_ref |= 1;
7440         }
7441         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7442 }
7443 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7444         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7445         int8_tArray their_node_id_arr = init_int8_tArray(33);
7446         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7447         LDKFundingLocked msg_var = *msg;
7448         uint64_t msg_ref = 0;
7449         msg_var = FundingLocked_clone(msg);
7450         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7451         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7452         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7453         msg_ref = (uint64_t)msg_var.inner;
7454         if (msg_var.is_owned) {
7455                 msg_ref |= 1;
7456         }
7457         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7458 }
7459 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7460         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7461         int8_tArray their_node_id_arr = init_int8_tArray(33);
7462         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7463         LDKInitFeatures their_features_var = *their_features;
7464         uint64_t their_features_ref = 0;
7465         their_features_var = InitFeatures_clone(their_features);
7466         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7467         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7468         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7469         their_features_ref = (uint64_t)their_features_var.inner;
7470         if (their_features_var.is_owned) {
7471                 their_features_ref |= 1;
7472         }
7473         LDKShutdown msg_var = *msg;
7474         uint64_t msg_ref = 0;
7475         msg_var = Shutdown_clone(msg);
7476         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7477         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7479         msg_ref = (uint64_t)msg_var.inner;
7480         if (msg_var.is_owned) {
7481                 msg_ref |= 1;
7482         }
7483         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7484 }
7485 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7486         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7487         int8_tArray their_node_id_arr = init_int8_tArray(33);
7488         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7489         LDKClosingSigned msg_var = *msg;
7490         uint64_t msg_ref = 0;
7491         msg_var = ClosingSigned_clone(msg);
7492         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7493         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7494         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7495         msg_ref = (uint64_t)msg_var.inner;
7496         if (msg_var.is_owned) {
7497                 msg_ref |= 1;
7498         }
7499         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7500 }
7501 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7502         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7503         int8_tArray their_node_id_arr = init_int8_tArray(33);
7504         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7505         LDKUpdateAddHTLC msg_var = *msg;
7506         uint64_t msg_ref = 0;
7507         msg_var = UpdateAddHTLC_clone(msg);
7508         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7509         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7510         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7511         msg_ref = (uint64_t)msg_var.inner;
7512         if (msg_var.is_owned) {
7513                 msg_ref |= 1;
7514         }
7515         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7516 }
7517 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7518         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7519         int8_tArray their_node_id_arr = init_int8_tArray(33);
7520         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7521         LDKUpdateFulfillHTLC msg_var = *msg;
7522         uint64_t msg_ref = 0;
7523         msg_var = UpdateFulfillHTLC_clone(msg);
7524         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7525         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7526         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7527         msg_ref = (uint64_t)msg_var.inner;
7528         if (msg_var.is_owned) {
7529                 msg_ref |= 1;
7530         }
7531         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7532 }
7533 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7534         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7535         int8_tArray their_node_id_arr = init_int8_tArray(33);
7536         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7537         LDKUpdateFailHTLC msg_var = *msg;
7538         uint64_t msg_ref = 0;
7539         msg_var = UpdateFailHTLC_clone(msg);
7540         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7541         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7542         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7543         msg_ref = (uint64_t)msg_var.inner;
7544         if (msg_var.is_owned) {
7545                 msg_ref |= 1;
7546         }
7547         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7548 }
7549 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7550         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7551         int8_tArray their_node_id_arr = init_int8_tArray(33);
7552         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7553         LDKUpdateFailMalformedHTLC msg_var = *msg;
7554         uint64_t msg_ref = 0;
7555         msg_var = UpdateFailMalformedHTLC_clone(msg);
7556         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7557         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7558         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7559         msg_ref = (uint64_t)msg_var.inner;
7560         if (msg_var.is_owned) {
7561                 msg_ref |= 1;
7562         }
7563         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7564 }
7565 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7566         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7567         int8_tArray their_node_id_arr = init_int8_tArray(33);
7568         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7569         LDKCommitmentSigned msg_var = *msg;
7570         uint64_t msg_ref = 0;
7571         msg_var = CommitmentSigned_clone(msg);
7572         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7573         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7574         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7575         msg_ref = (uint64_t)msg_var.inner;
7576         if (msg_var.is_owned) {
7577                 msg_ref |= 1;
7578         }
7579         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7580 }
7581 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7582         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7583         int8_tArray their_node_id_arr = init_int8_tArray(33);
7584         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7585         LDKRevokeAndACK msg_var = *msg;
7586         uint64_t msg_ref = 0;
7587         msg_var = RevokeAndACK_clone(msg);
7588         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7589         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7591         msg_ref = (uint64_t)msg_var.inner;
7592         if (msg_var.is_owned) {
7593                 msg_ref |= 1;
7594         }
7595         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7596 }
7597 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7598         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7599         int8_tArray their_node_id_arr = init_int8_tArray(33);
7600         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7601         LDKUpdateFee msg_var = *msg;
7602         uint64_t msg_ref = 0;
7603         msg_var = UpdateFee_clone(msg);
7604         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7605         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7606         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7607         msg_ref = (uint64_t)msg_var.inner;
7608         if (msg_var.is_owned) {
7609                 msg_ref |= 1;
7610         }
7611         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7612 }
7613 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7614         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7615         int8_tArray their_node_id_arr = init_int8_tArray(33);
7616         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7617         LDKAnnouncementSignatures msg_var = *msg;
7618         uint64_t msg_ref = 0;
7619         msg_var = AnnouncementSignatures_clone(msg);
7620         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7621         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7622         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7623         msg_ref = (uint64_t)msg_var.inner;
7624         if (msg_var.is_owned) {
7625                 msg_ref |= 1;
7626         }
7627         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7628 }
7629 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7630         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7631         int8_tArray their_node_id_arr = init_int8_tArray(33);
7632         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7633         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
7634 }
7635 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7636         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7637         int8_tArray their_node_id_arr = init_int8_tArray(33);
7638         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7639         LDKInit msg_var = *msg;
7640         uint64_t msg_ref = 0;
7641         msg_var = Init_clone(msg);
7642         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7643         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7644         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7645         msg_ref = (uint64_t)msg_var.inner;
7646         if (msg_var.is_owned) {
7647                 msg_ref |= 1;
7648         }
7649         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7650 }
7651 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7653         int8_tArray their_node_id_arr = init_int8_tArray(33);
7654         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7655         LDKChannelReestablish msg_var = *msg;
7656         uint64_t msg_ref = 0;
7657         msg_var = ChannelReestablish_clone(msg);
7658         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7659         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7661         msg_ref = (uint64_t)msg_var.inner;
7662         if (msg_var.is_owned) {
7663                 msg_ref |= 1;
7664         }
7665         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7666 }
7667 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7669         int8_tArray their_node_id_arr = init_int8_tArray(33);
7670         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7671         LDKChannelUpdate msg_var = *msg;
7672         uint64_t msg_ref = 0;
7673         msg_var = ChannelUpdate_clone(msg);
7674         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7675         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7677         msg_ref = (uint64_t)msg_var.inner;
7678         if (msg_var.is_owned) {
7679                 msg_ref |= 1;
7680         }
7681         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7682 }
7683 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7684         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7685         int8_tArray their_node_id_arr = init_int8_tArray(33);
7686         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7687         LDKErrorMessage msg_var = *msg;
7688         uint64_t msg_ref = 0;
7689         msg_var = ErrorMessage_clone(msg);
7690         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7693         msg_ref = (uint64_t)msg_var.inner;
7694         if (msg_var.is_owned) {
7695                 msg_ref |= 1;
7696         }
7697         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7698 }
7699 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7700         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7701         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7702         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7703 }
7704 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
7705         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7706         atomic_init(&calls->refcnt, 1);
7707         calls->instance_ptr = o;
7708
7709         LDKChannelMessageHandler ret = {
7710                 .this_arg = (void*) calls,
7711                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7712                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7713                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7714                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7715                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7716                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7717                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7718                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7719                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7720                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7721                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7722                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7723                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7724                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7725                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7726                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7727                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7728                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7729                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7730                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7731                 .free = LDKChannelMessageHandler_JCalls_free,
7732                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
7733         };
7734         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7735         return ret;
7736 }
7737 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
7738         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7739         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
7740         return (long)res_ptr;
7741 }
7742 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) {
7743         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7746         LDKPublicKey their_node_id_ref;
7747         CHECK(their_node_id->arr_len == 33);
7748         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7749         LDKInitFeatures their_features_conv;
7750         their_features_conv.inner = (void*)(their_features & (~1));
7751         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7752         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7753         their_features_conv = InitFeatures_clone(&their_features_conv);
7754         LDKOpenChannel msg_conv;
7755         msg_conv.inner = (void*)(msg & (~1));
7756         msg_conv.is_owned = false;
7757         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7758         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7759 }
7760
7761 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) {
7762         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7763         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7764         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7765         LDKPublicKey their_node_id_ref;
7766         CHECK(their_node_id->arr_len == 33);
7767         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7768         LDKInitFeatures their_features_conv;
7769         their_features_conv.inner = (void*)(their_features & (~1));
7770         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7771         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7772         their_features_conv = InitFeatures_clone(&their_features_conv);
7773         LDKAcceptChannel msg_conv;
7774         msg_conv.inner = (void*)(msg & (~1));
7775         msg_conv.is_owned = false;
7776         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7777         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7778 }
7779
7780 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) {
7781         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7782         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7783         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7784         LDKPublicKey their_node_id_ref;
7785         CHECK(their_node_id->arr_len == 33);
7786         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7787         LDKFundingCreated msg_conv;
7788         msg_conv.inner = (void*)(msg & (~1));
7789         msg_conv.is_owned = false;
7790         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7791         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7792 }
7793
7794 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) {
7795         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7796         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7797         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7798         LDKPublicKey their_node_id_ref;
7799         CHECK(their_node_id->arr_len == 33);
7800         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7801         LDKFundingSigned msg_conv;
7802         msg_conv.inner = (void*)(msg & (~1));
7803         msg_conv.is_owned = false;
7804         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7805         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7806 }
7807
7808 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) {
7809         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7810         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7811         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7812         LDKPublicKey their_node_id_ref;
7813         CHECK(their_node_id->arr_len == 33);
7814         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7815         LDKFundingLocked msg_conv;
7816         msg_conv.inner = (void*)(msg & (~1));
7817         msg_conv.is_owned = false;
7818         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7819         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7820 }
7821
7822 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) {
7823         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7824         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7825         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7826         LDKPublicKey their_node_id_ref;
7827         CHECK(their_node_id->arr_len == 33);
7828         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7829         LDKInitFeatures their_features_conv;
7830         their_features_conv.inner = (void*)(their_features & (~1));
7831         their_features_conv.is_owned = false;
7832         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7833         LDKShutdown msg_conv;
7834         msg_conv.inner = (void*)(msg & (~1));
7835         msg_conv.is_owned = false;
7836         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7837         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7838 }
7839
7840 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) {
7841         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7842         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7843         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7844         LDKPublicKey their_node_id_ref;
7845         CHECK(their_node_id->arr_len == 33);
7846         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7847         LDKClosingSigned msg_conv;
7848         msg_conv.inner = (void*)(msg & (~1));
7849         msg_conv.is_owned = false;
7850         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7851         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7852 }
7853
7854 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) {
7855         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7856         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7857         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7858         LDKPublicKey their_node_id_ref;
7859         CHECK(their_node_id->arr_len == 33);
7860         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7861         LDKUpdateAddHTLC msg_conv;
7862         msg_conv.inner = (void*)(msg & (~1));
7863         msg_conv.is_owned = false;
7864         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7865         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7866 }
7867
7868 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) {
7869         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7870         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7871         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7872         LDKPublicKey their_node_id_ref;
7873         CHECK(their_node_id->arr_len == 33);
7874         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7875         LDKUpdateFulfillHTLC msg_conv;
7876         msg_conv.inner = (void*)(msg & (~1));
7877         msg_conv.is_owned = false;
7878         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7879         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7880 }
7881
7882 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) {
7883         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7884         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7885         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7886         LDKPublicKey their_node_id_ref;
7887         CHECK(their_node_id->arr_len == 33);
7888         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7889         LDKUpdateFailHTLC msg_conv;
7890         msg_conv.inner = (void*)(msg & (~1));
7891         msg_conv.is_owned = false;
7892         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7893         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7894 }
7895
7896 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) {
7897         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7898         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7899         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7900         LDKPublicKey their_node_id_ref;
7901         CHECK(their_node_id->arr_len == 33);
7902         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7903         LDKUpdateFailMalformedHTLC msg_conv;
7904         msg_conv.inner = (void*)(msg & (~1));
7905         msg_conv.is_owned = false;
7906         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7907         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7908 }
7909
7910 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) {
7911         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7912         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7913         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7914         LDKPublicKey their_node_id_ref;
7915         CHECK(their_node_id->arr_len == 33);
7916         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7917         LDKCommitmentSigned msg_conv;
7918         msg_conv.inner = (void*)(msg & (~1));
7919         msg_conv.is_owned = false;
7920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7921         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7922 }
7923
7924 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) {
7925         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7927         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7928         LDKPublicKey their_node_id_ref;
7929         CHECK(their_node_id->arr_len == 33);
7930         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7931         LDKRevokeAndACK msg_conv;
7932         msg_conv.inner = (void*)(msg & (~1));
7933         msg_conv.is_owned = false;
7934         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7935         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7936 }
7937
7938 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) {
7939         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7940         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7941         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7942         LDKPublicKey their_node_id_ref;
7943         CHECK(their_node_id->arr_len == 33);
7944         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7945         LDKUpdateFee msg_conv;
7946         msg_conv.inner = (void*)(msg & (~1));
7947         msg_conv.is_owned = false;
7948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7949         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7950 }
7951
7952 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) {
7953         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7954         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7955         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7956         LDKPublicKey their_node_id_ref;
7957         CHECK(their_node_id->arr_len == 33);
7958         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7959         LDKAnnouncementSignatures msg_conv;
7960         msg_conv.inner = (void*)(msg & (~1));
7961         msg_conv.is_owned = false;
7962         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7963         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7964 }
7965
7966 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) {
7967         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7968         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7969         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7970         LDKPublicKey their_node_id_ref;
7971         CHECK(their_node_id->arr_len == 33);
7972         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7973         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7974 }
7975
7976 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7977         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7978         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7980         LDKPublicKey their_node_id_ref;
7981         CHECK(their_node_id->arr_len == 33);
7982         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7983         LDKInit msg_conv;
7984         msg_conv.inner = (void*)(msg & (~1));
7985         msg_conv.is_owned = false;
7986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7987         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7988 }
7989
7990 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) {
7991         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7993         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7994         LDKPublicKey their_node_id_ref;
7995         CHECK(their_node_id->arr_len == 33);
7996         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
7997         LDKChannelReestablish msg_conv;
7998         msg_conv.inner = (void*)(msg & (~1));
7999         msg_conv.is_owned = false;
8000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8001         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8002 }
8003
8004 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) {
8005         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8007         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8008         LDKPublicKey their_node_id_ref;
8009         CHECK(their_node_id->arr_len == 33);
8010         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8011         LDKChannelUpdate msg_conv;
8012         msg_conv.inner = (void*)(msg & (~1));
8013         msg_conv.is_owned = false;
8014         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8015         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8016 }
8017
8018 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
8019         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8020         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8021         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8022         LDKPublicKey their_node_id_ref;
8023         CHECK(their_node_id->arr_len == 33);
8024         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8025         LDKErrorMessage msg_conv;
8026         msg_conv.inner = (void*)(msg & (~1));
8027         msg_conv.is_owned = false;
8028         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8029         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8030 }
8031
8032 typedef struct LDKRoutingMessageHandler_JCalls {
8033         atomic_size_t refcnt;
8034         uint32_t instance_ptr;
8035         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8036 } LDKRoutingMessageHandler_JCalls;
8037 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8038         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8039         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8040                 FREE(j_calls);
8041         }
8042 }
8043 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8044         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8045         LDKNodeAnnouncement msg_var = *msg;
8046         uint64_t msg_ref = 0;
8047         msg_var = NodeAnnouncement_clone(msg);
8048         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8049         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8050         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8051         msg_ref = (uint64_t)msg_var.inner;
8052         if (msg_var.is_owned) {
8053                 msg_ref |= 1;
8054         }
8055         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
8056         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8057         CHECK_ACCESS(ret_ptr);
8058         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8059         FREE((void*)ret);
8060         return ret_conv;
8061 }
8062 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8063         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8064         LDKChannelAnnouncement msg_var = *msg;
8065         uint64_t msg_ref = 0;
8066         msg_var = ChannelAnnouncement_clone(msg);
8067         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8068         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8069         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8070         msg_ref = (uint64_t)msg_var.inner;
8071         if (msg_var.is_owned) {
8072                 msg_ref |= 1;
8073         }
8074         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
8075         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8076         CHECK_ACCESS(ret_ptr);
8077         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8078         FREE((void*)ret);
8079         return ret_conv;
8080 }
8081 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8082         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8083         LDKChannelUpdate msg_var = *msg;
8084         uint64_t msg_ref = 0;
8085         msg_var = ChannelUpdate_clone(msg);
8086         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8087         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8089         msg_ref = (uint64_t)msg_var.inner;
8090         if (msg_var.is_owned) {
8091                 msg_ref |= 1;
8092         }
8093         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
8094         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8095         CHECK_ACCESS(ret_ptr);
8096         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8097         FREE((void*)ret);
8098         return ret_conv;
8099 }
8100 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8101         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8102         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
8103         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8104         ret_constr.datalen = ret->arr_len;
8105         if (ret_constr.datalen > 0)
8106                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8107         else
8108                 ret_constr.data = NULL;
8109         uint32_t* ret_vals = ret->elems;
8110         for (size_t h = 0; h < ret_constr.datalen; h++) {
8111                 uint32_t ret_conv_59 = ret_vals[h];
8112                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
8113                 CHECK_ACCESS(ret_conv_59_ptr);
8114                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
8115                 FREE((void*)ret_conv_59);
8116                 ret_constr.data[h] = ret_conv_59_conv;
8117         }
8118         return ret_constr;
8119 }
8120 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8121         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8122         int8_tArray starting_point_arr = init_int8_tArray(33);
8123         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
8124         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
8125         LDKCVec_NodeAnnouncementZ ret_constr;
8126         ret_constr.datalen = ret->arr_len;
8127         if (ret_constr.datalen > 0)
8128                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8129         else
8130                 ret_constr.data = NULL;
8131         uint32_t* ret_vals = ret->elems;
8132         for (size_t s = 0; s < ret_constr.datalen; s++) {
8133                 uint32_t ret_conv_18 = ret_vals[s];
8134                 LDKNodeAnnouncement ret_conv_18_conv;
8135                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8136                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8137                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
8138                 ret_constr.data[s] = ret_conv_18_conv;
8139         }
8140         return ret_constr;
8141 }
8142 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8143         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8144         int8_tArray their_node_id_arr = init_int8_tArray(33);
8145         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8146         LDKInit init_var = *init;
8147         uint64_t init_ref = 0;
8148         init_var = Init_clone(init);
8149         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8150         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8151         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
8152         init_ref = (uint64_t)init_var.inner;
8153         if (init_var.is_owned) {
8154                 init_ref |= 1;
8155         }
8156         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
8157 }
8158 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8159         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8160         int8_tArray their_node_id_arr = init_int8_tArray(33);
8161         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8162         LDKReplyChannelRange msg_var = msg;
8163         uint64_t msg_ref = 0;
8164         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8165         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8166         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8167         msg_ref = (uint64_t)msg_var.inner;
8168         if (msg_var.is_owned) {
8169                 msg_ref |= 1;
8170         }
8171         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8172         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8173         CHECK_ACCESS(ret_ptr);
8174         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8175         FREE((void*)ret);
8176         return ret_conv;
8177 }
8178 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8179         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8180         int8_tArray their_node_id_arr = init_int8_tArray(33);
8181         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8182         LDKReplyShortChannelIdsEnd msg_var = msg;
8183         uint64_t msg_ref = 0;
8184         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8185         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8186         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8187         msg_ref = (uint64_t)msg_var.inner;
8188         if (msg_var.is_owned) {
8189                 msg_ref |= 1;
8190         }
8191         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8192         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8193         CHECK_ACCESS(ret_ptr);
8194         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8195         FREE((void*)ret);
8196         return ret_conv;
8197 }
8198 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8199         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8200         int8_tArray their_node_id_arr = init_int8_tArray(33);
8201         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8202         LDKQueryChannelRange msg_var = msg;
8203         uint64_t msg_ref = 0;
8204         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8205         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8206         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8207         msg_ref = (uint64_t)msg_var.inner;
8208         if (msg_var.is_owned) {
8209                 msg_ref |= 1;
8210         }
8211         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8212         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8213         CHECK_ACCESS(ret_ptr);
8214         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8215         FREE((void*)ret);
8216         return ret_conv;
8217 }
8218 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8219         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8220         int8_tArray their_node_id_arr = init_int8_tArray(33);
8221         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8222         LDKQueryShortChannelIds msg_var = msg;
8223         uint64_t msg_ref = 0;
8224         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8225         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8227         msg_ref = (uint64_t)msg_var.inner;
8228         if (msg_var.is_owned) {
8229                 msg_ref |= 1;
8230         }
8231         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8232         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8233         CHECK_ACCESS(ret_ptr);
8234         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8235         FREE((void*)ret);
8236         return ret_conv;
8237 }
8238 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8239         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8240         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8241         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8242 }
8243 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8244         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8245         atomic_init(&calls->refcnt, 1);
8246         calls->instance_ptr = o;
8247
8248         LDKRoutingMessageHandler ret = {
8249                 .this_arg = (void*) calls,
8250                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8251                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8252                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8253                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8254                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8255                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8256                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8257                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8258                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8259                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8260                 .free = LDKRoutingMessageHandler_JCalls_free,
8261                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8262         };
8263         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8264         return ret;
8265 }
8266 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8267         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8268         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
8269         return (long)res_ptr;
8270 }
8271 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
8272         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8273         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8274         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8275         LDKNodeAnnouncement msg_conv;
8276         msg_conv.inner = (void*)(msg & (~1));
8277         msg_conv.is_owned = false;
8278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8279         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8280         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8281         return (uint64_t)ret_conv;
8282 }
8283
8284 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
8285         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8287         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8288         LDKChannelAnnouncement 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_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8294         return (uint64_t)ret_conv;
8295 }
8296
8297 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
8298         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8300         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8301         LDKChannelUpdate 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_update)(this_arg_conv->this_arg, &msg_conv);
8307         return (uint64_t)ret_conv;
8308 }
8309
8310 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) {
8311         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8312         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8313         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8314         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8315         uint32_tArray ret_arr = NULL;
8316         ret_arr = init_uint32_tArray(ret_var.datalen);
8317         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8318         for (size_t h = 0; h < ret_var.datalen; h++) {
8319                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8320                 *ret_conv_59_conv = ret_var.data[h];
8321                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
8322         }
8323         
8324         FREE(ret_var.data);
8325         return ret_arr;
8326 }
8327
8328 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) {
8329         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8330         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8331         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8332         LDKPublicKey starting_point_ref;
8333         CHECK(starting_point->arr_len == 33);
8334         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33);
8335         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8336         uint32_tArray ret_arr = NULL;
8337         ret_arr = init_uint32_tArray(ret_var.datalen);
8338         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8339         for (size_t s = 0; s < ret_var.datalen; s++) {
8340                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8341                 uint64_t ret_conv_18_ref = 0;
8342                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8343                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
8345                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8346                 if (ret_conv_18_var.is_owned) {
8347                         ret_conv_18_ref |= 1;
8348                 }
8349                 ret_arr_ptr[s] = ret_conv_18_ref;
8350         }
8351         
8352         FREE(ret_var.data);
8353         return ret_arr;
8354 }
8355
8356 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) {
8357         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8358         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8359         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8360         LDKPublicKey their_node_id_ref;
8361         CHECK(their_node_id->arr_len == 33);
8362         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8363         LDKInit init_conv;
8364         init_conv.inner = (void*)(init & (~1));
8365         init_conv.is_owned = false;
8366         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
8367         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8368 }
8369
8370 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) {
8371         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8373         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8374         LDKPublicKey their_node_id_ref;
8375         CHECK(their_node_id->arr_len == 33);
8376         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8377         LDKReplyChannelRange msg_conv;
8378         msg_conv.inner = (void*)(msg & (~1));
8379         msg_conv.is_owned = (msg & 1) || (msg == 0);
8380         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8381         msg_conv = ReplyChannelRange_clone(&msg_conv);
8382         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8383         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8384         return (uint64_t)ret_conv;
8385 }
8386
8387 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) {
8388         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8390         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8391         LDKPublicKey their_node_id_ref;
8392         CHECK(their_node_id->arr_len == 33);
8393         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8394         LDKReplyShortChannelIdsEnd msg_conv;
8395         msg_conv.inner = (void*)(msg & (~1));
8396         msg_conv.is_owned = (msg & 1) || (msg == 0);
8397         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8398         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8399         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8400         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8401         return (uint64_t)ret_conv;
8402 }
8403
8404 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) {
8405         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8407         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8408         LDKPublicKey their_node_id_ref;
8409         CHECK(their_node_id->arr_len == 33);
8410         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8411         LDKQueryChannelRange msg_conv;
8412         msg_conv.inner = (void*)(msg & (~1));
8413         msg_conv.is_owned = (msg & 1) || (msg == 0);
8414         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8415         msg_conv = QueryChannelRange_clone(&msg_conv);
8416         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8417         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8418         return (uint64_t)ret_conv;
8419 }
8420
8421 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) {
8422         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8423         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8424         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8425         LDKPublicKey their_node_id_ref;
8426         CHECK(their_node_id->arr_len == 33);
8427         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
8428         LDKQueryShortChannelIds msg_conv;
8429         msg_conv.inner = (void*)(msg & (~1));
8430         msg_conv.is_owned = (msg & 1) || (msg == 0);
8431         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8432         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8433         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8434         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8435         return (uint64_t)ret_conv;
8436 }
8437
8438 typedef struct LDKCustomMessageReader_JCalls {
8439         atomic_size_t refcnt;
8440         uint32_t instance_ptr;
8441 } LDKCustomMessageReader_JCalls;
8442 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
8443         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8444         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8445                 FREE(j_calls);
8446         }
8447 }
8448 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
8449         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8450         LDKu8slice buffer_var = buffer;
8451         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen);
8452         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
8453         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
8454         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8455         CHECK_ACCESS(ret_ptr);
8456         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
8457         FREE((void*)ret);
8458         return ret_conv;
8459 }
8460 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
8461         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
8462         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8463 }
8464 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
8465         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
8466         atomic_init(&calls->refcnt, 1);
8467         calls->instance_ptr = o;
8468
8469         LDKCustomMessageReader ret = {
8470                 .this_arg = (void*) calls,
8471                 .read = read_LDKCustomMessageReader_jcall,
8472                 .free = LDKCustomMessageReader_JCalls_free,
8473         };
8474         return ret;
8475 }
8476 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
8477         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
8478         *res_ptr = LDKCustomMessageReader_init(o);
8479         return (long)res_ptr;
8480 }
8481 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
8482         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8483         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8484         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
8485         LDKu8slice buffer_ref;
8486         buffer_ref.datalen = buffer->arr_len;
8487         buffer_ref.data = buffer->elems;
8488         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
8489         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
8490         return (uint64_t)ret_conv;
8491 }
8492
8493 typedef struct LDKCustomMessageHandler_JCalls {
8494         atomic_size_t refcnt;
8495         uint32_t instance_ptr;
8496         LDKCustomMessageReader_JCalls* CustomMessageReader;
8497 } LDKCustomMessageHandler_JCalls;
8498 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
8499         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8500         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8501                 FREE(j_calls);
8502         }
8503 }
8504 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
8505         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8506         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
8507         *msg_ret = msg;
8508         int8_tArray sender_node_id_arr = init_int8_tArray(33);
8509         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
8510         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint64_t)msg_ret, (uint32_t)sender_node_id_arr);
8511         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8512         CHECK_ACCESS(ret_ptr);
8513         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8514         FREE((void*)ret);
8515         return ret_conv;
8516 }
8517 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
8518         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8519         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
8520         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
8521         ret_constr.datalen = ret->arr_len;
8522         if (ret_constr.datalen > 0)
8523                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
8524         else
8525                 ret_constr.data = NULL;
8526         uint32_t* ret_vals = ret->elems;
8527         for (size_t z = 0; z < ret_constr.datalen; z++) {
8528                 uint32_t ret_conv_25 = ret_vals[z];
8529                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
8530                 CHECK_ACCESS(ret_conv_25_ptr);
8531                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
8532                 FREE((void*)ret_conv_25);
8533                 ret_constr.data[z] = ret_conv_25_conv;
8534         }
8535         return ret_constr;
8536 }
8537 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
8538         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
8539         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8540         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
8541 }
8542 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
8543         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
8544         atomic_init(&calls->refcnt, 1);
8545         calls->instance_ptr = o;
8546
8547         LDKCustomMessageHandler ret = {
8548                 .this_arg = (void*) calls,
8549                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
8550                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
8551                 .free = LDKCustomMessageHandler_JCalls_free,
8552                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
8553         };
8554         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
8555         return ret;
8556 }
8557 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
8558         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
8559         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
8560         return (long)res_ptr;
8561 }
8562 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) {
8563         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8565         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8566         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
8567         CHECK_ACCESS(msg_ptr);
8568         LDKType msg_conv = *(LDKType*)(msg_ptr);
8569         LDKPublicKey sender_node_id_ref;
8570         CHECK(sender_node_id->arr_len == 33);
8571         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33);
8572         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8573         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
8574         return (uint64_t)ret_conv;
8575 }
8576
8577 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
8578         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8580         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8581         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
8582         uint32_tArray ret_arr = NULL;
8583         ret_arr = init_uint32_tArray(ret_var.datalen);
8584         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8585         for (size_t z = 0; z < ret_var.datalen; z++) {
8586                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
8587                 *ret_conv_25_conv = ret_var.data[z];
8588                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
8589         }
8590         
8591         FREE(ret_var.data);
8592         return ret_arr;
8593 }
8594
8595 typedef struct LDKSocketDescriptor_JCalls {
8596         atomic_size_t refcnt;
8597         uint32_t instance_ptr;
8598 } LDKSocketDescriptor_JCalls;
8599 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8600         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8601         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8602                 FREE(j_calls);
8603         }
8604 }
8605 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8606         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8607         LDKu8slice data_var = data;
8608         int8_tArray data_arr = init_int8_tArray(data_var.datalen);
8609         memcpy(data_arr->elems, data_var.data, data_var.datalen);
8610         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
8611 }
8612 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8613         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8614         js_invoke_function_0(j_calls->instance_ptr, 79);
8615 }
8616 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8617         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8618         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8619         *other_arg_clone = SocketDescriptor_clone(other_arg);
8620         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint64_t)other_arg_clone);
8621 }
8622 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8623         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8624         return js_invoke_function_0(j_calls->instance_ptr, 81);
8625 }
8626 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8627         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8628         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8629 }
8630 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
8631         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8632         atomic_init(&calls->refcnt, 1);
8633         calls->instance_ptr = o;
8634
8635         LDKSocketDescriptor ret = {
8636                 .this_arg = (void*) calls,
8637                 .send_data = send_data_LDKSocketDescriptor_jcall,
8638                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8639                 .eq = eq_LDKSocketDescriptor_jcall,
8640                 .hash = hash_LDKSocketDescriptor_jcall,
8641                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8642                 .free = LDKSocketDescriptor_JCalls_free,
8643         };
8644         return ret;
8645 }
8646 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
8647         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8648         *res_ptr = LDKSocketDescriptor_init(o);
8649         return (long)res_ptr;
8650 }
8651 int64_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
8652         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8653         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8654         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8655         LDKu8slice data_ref;
8656         data_ref.datalen = data->arr_len;
8657         data_ref.data = data->elems;
8658         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8659         return ret_val;
8660 }
8661
8662 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
8663         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8665         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8666         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8667 }
8668
8669 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
8670         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8671         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8672         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8673         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8674         return ret_val;
8675 }
8676
8677 typedef struct LDKScore_JCalls {
8678         atomic_size_t refcnt;
8679         uint32_t instance_ptr;
8680 } LDKScore_JCalls;
8681 static void LDKScore_JCalls_free(void* this_arg) {
8682         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8683         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8684                 FREE(j_calls);
8685         }
8686 }
8687 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) {
8688         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8689         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8690         *channel_capacity_msat_copy = channel_capacity_msat;
8691         uint64_t channel_capacity_msat_ref = (uint64_t)channel_capacity_msat_copy;
8692         LDKNodeId source_var = *source;
8693         uint64_t source_ref = 0;
8694         source_var = NodeId_clone(source);
8695         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8696         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8697         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8698         source_ref = (uint64_t)source_var.inner;
8699         if (source_var.is_owned) {
8700                 source_ref |= 1;
8701         }
8702         LDKNodeId target_var = *target;
8703         uint64_t target_ref = 0;
8704         target_var = NodeId_clone(target);
8705         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8706         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8707         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8708         target_ref = (uint64_t)target_var.inner;
8709         if (target_var.is_owned) {
8710                 target_ref |= 1;
8711         }
8712         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);
8713 }
8714 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8715         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8716         LDKCVec_RouteHopZ path_var = path;
8717         uint32_tArray path_arr = NULL;
8718         path_arr = init_uint32_tArray(path_var.datalen);
8719         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8720         for (size_t k = 0; k < path_var.datalen; k++) {
8721                 LDKRouteHop path_conv_10_var = path_var.data[k];
8722                 uint64_t path_conv_10_ref = 0;
8723                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8724                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8725                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8726                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
8727                 if (path_conv_10_var.is_owned) {
8728                         path_conv_10_ref |= 1;
8729                 }
8730                 path_arr_ptr[k] = path_conv_10_ref;
8731         }
8732         
8733         FREE(path_var.data);
8734         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
8735 }
8736 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8737         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8738         LDKCVec_RouteHopZ path_var = path;
8739         uint32_tArray path_arr = NULL;
8740         path_arr = init_uint32_tArray(path_var.datalen);
8741         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8742         for (size_t k = 0; k < path_var.datalen; k++) {
8743                 LDKRouteHop path_conv_10_var = path_var.data[k];
8744                 uint64_t path_conv_10_ref = 0;
8745                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8746                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8747                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8748                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
8749                 if (path_conv_10_var.is_owned) {
8750                         path_conv_10_ref |= 1;
8751                 }
8752                 path_arr_ptr[k] = path_conv_10_ref;
8753         }
8754         
8755         FREE(path_var.data);
8756         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
8757 }
8758 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8759         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8760         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
8761         LDKCVec_u8Z ret_ref;
8762         ret_ref.datalen = ret->arr_len;
8763         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8764         memcpy(ret_ref.data, ret->elems, ret_ref.datalen);
8765         return ret_ref;
8766 }
8767 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8768         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8769         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8770 }
8771 static inline LDKScore LDKScore_init (JSValue o) {
8772         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8773         atomic_init(&calls->refcnt, 1);
8774         calls->instance_ptr = o;
8775
8776         LDKScore ret = {
8777                 .this_arg = (void*) calls,
8778                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8779                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8780                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8781                 .write = write_LDKScore_jcall,
8782                 .free = LDKScore_JCalls_free,
8783         };
8784         return ret;
8785 }
8786 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8787         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8788         *res_ptr = LDKScore_init(o);
8789         return (long)res_ptr;
8790 }
8791 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) {
8792         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8793         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8794         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8795         void* channel_capacity_msat_ptr = (void*)(((uint64_t)channel_capacity_msat) & ~1);
8796         CHECK_ACCESS(channel_capacity_msat_ptr);
8797         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
8798         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)channel_capacity_msat) & ~1));
8799         LDKNodeId source_conv;
8800         source_conv.inner = (void*)(source & (~1));
8801         source_conv.is_owned = false;
8802         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8803         LDKNodeId target_conv;
8804         target_conv.inner = (void*)(target & (~1));
8805         target_conv.is_owned = false;
8806         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8807         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);
8808         return ret_val;
8809 }
8810
8811 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) {
8812         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8813         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8814         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8815         LDKCVec_RouteHopZ path_constr;
8816         path_constr.datalen = path->arr_len;
8817         if (path_constr.datalen > 0)
8818                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8819         else
8820                 path_constr.data = NULL;
8821         uint32_t* path_vals = path->elems;
8822         for (size_t k = 0; k < path_constr.datalen; k++) {
8823                 uint32_t path_conv_10 = path_vals[k];
8824                 LDKRouteHop path_conv_10_conv;
8825                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8826                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8827                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8828                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8829                 path_constr.data[k] = path_conv_10_conv;
8830         }
8831         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8832 }
8833
8834 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8835         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8836         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8837         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8838         LDKCVec_RouteHopZ path_constr;
8839         path_constr.datalen = path->arr_len;
8840         if (path_constr.datalen > 0)
8841                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8842         else
8843                 path_constr.data = NULL;
8844         uint32_t* path_vals = path->elems;
8845         for (size_t k = 0; k < path_constr.datalen; k++) {
8846                 uint32_t path_conv_10 = path_vals[k];
8847                 LDKRouteHop path_conv_10_conv;
8848                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8849                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8850                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8851                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8852                 path_constr.data[k] = path_conv_10_conv;
8853         }
8854         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8855 }
8856
8857 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8858         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8859         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8860         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8861         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8862         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
8863         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8864         CVec_u8Z_free(ret_var);
8865         return ret_arr;
8866 }
8867
8868 typedef struct LDKLockableScore_JCalls {
8869         atomic_size_t refcnt;
8870         uint32_t instance_ptr;
8871 } LDKLockableScore_JCalls;
8872 static void LDKLockableScore_JCalls_free(void* this_arg) {
8873         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8874         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8875                 FREE(j_calls);
8876         }
8877 }
8878 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
8879         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8880         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
8881         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8882         CHECK_ACCESS(ret_ptr);
8883         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// Warning: we may need a move here but no clone is available for LDKScore
8884         
8885         return ret_conv;
8886 }
8887 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
8888         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
8889         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8890 }
8891 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
8892         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
8893         atomic_init(&calls->refcnt, 1);
8894         calls->instance_ptr = o;
8895
8896         LDKLockableScore ret = {
8897                 .this_arg = (void*) calls,
8898                 .lock = lock_LDKLockableScore_jcall,
8899                 .free = LDKLockableScore_JCalls_free,
8900         };
8901         return ret;
8902 }
8903 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
8904         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
8905         *res_ptr = LDKLockableScore_init(o);
8906         return (long)res_ptr;
8907 }
8908 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
8909         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8910         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8911         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
8912         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
8913         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
8914         return (uint64_t)ret_ret;
8915 }
8916
8917 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
8918         LDKStr ret_str = _ldk_get_compiled_version();
8919         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8920         Str_free(ret_str);
8921         return ret_conv;
8922 }
8923
8924 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
8925         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8926         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8927         Str_free(ret_str);
8928         return ret_conv;
8929 }
8930
8931 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
8932         LDKTransaction _res_ref;
8933         _res_ref.datalen = _res->arr_len;
8934         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8935         memcpy(_res_ref.data, _res->elems, _res_ref.datalen);
8936         _res_ref.data_is_owned = true;
8937         Transaction_free(_res_ref);
8938 }
8939
8940 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
8941         LDKCVec_u8Z script_pubkey_ref;
8942         script_pubkey_ref.datalen = script_pubkey->arr_len;
8943         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8944         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen);
8945         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8946         *ret_ref = TxOut_new(script_pubkey_ref, value);
8947         return (uint64_t)ret_ref;
8948 }
8949
8950 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
8951         if ((_res & 1) != 0) return;
8952         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8953         CHECK_ACCESS(_res_ptr);
8954         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
8955         FREE((void*)_res);
8956         TxOut_free(_res_conv);
8957 }
8958
8959 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
8960         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8961         *ret_ref = TxOut_clone(arg);
8962         return (uint64_t)ret_ref;
8963 }
8964 int64_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
8965         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
8966         int64_t ret_val = TxOut_clone_ptr(arg_conv);
8967         return ret_val;
8968 }
8969
8970 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
8971         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8972         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8973         *ret_ref = TxOut_clone(orig_conv);
8974         return (uint64_t)ret_ref;
8975 }
8976
8977 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
8978         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8979         Str_free(dummy);
8980 }
8981
8982 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8983         LDKChannelConfig o_conv;
8984         o_conv.inner = (void*)(o & (~1));
8985         o_conv.is_owned = (o & 1) || (o == 0);
8986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8987         o_conv = ChannelConfig_clone(&o_conv);
8988         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8989         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8990         return (uint64_t)ret_conv;
8991 }
8992
8993 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8994         LDKDecodeError e_conv;
8995         e_conv.inner = (void*)(e & (~1));
8996         e_conv.is_owned = (e & 1) || (e == 0);
8997         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8998         e_conv = DecodeError_clone(&e_conv);
8999         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9000         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9001         return (uint64_t)ret_conv;
9002 }
9003
9004 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
9005         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
9006         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
9007         return ret_val;
9008 }
9009
9010 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9011         if ((_res & 1) != 0) return;
9012         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9013         CHECK_ACCESS(_res_ptr);
9014         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
9015         FREE((void*)_res);
9016         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9017 }
9018
9019 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
9020         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9021         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
9022         return (uint64_t)ret_conv;
9023 }
9024 int64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
9025         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
9026         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
9027         return ret_val;
9028 }
9029
9030 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9031         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9032         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9033         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9034         return (uint64_t)ret_conv;
9035 }
9036
9037 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9038         LDKOutPoint o_conv;
9039         o_conv.inner = (void*)(o & (~1));
9040         o_conv.is_owned = (o & 1) || (o == 0);
9041         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9042         o_conv = OutPoint_clone(&o_conv);
9043         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9044         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9045         return (uint64_t)ret_conv;
9046 }
9047
9048 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9049         LDKDecodeError e_conv;
9050         e_conv.inner = (void*)(e & (~1));
9051         e_conv.is_owned = (e & 1) || (e == 0);
9052         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9053         e_conv = DecodeError_clone(&e_conv);
9054         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9055         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9056         return (uint64_t)ret_conv;
9057 }
9058
9059 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
9060         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
9061         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
9062         return ret_val;
9063 }
9064
9065 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9066         if ((_res & 1) != 0) return;
9067         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9068         CHECK_ACCESS(_res_ptr);
9069         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
9070         FREE((void*)_res);
9071         CResult_OutPointDecodeErrorZ_free(_res_conv);
9072 }
9073
9074 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
9075         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9076         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
9077         return (uint64_t)ret_conv;
9078 }
9079 int64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
9080         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
9081         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
9082         return ret_val;
9083 }
9084
9085 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9086         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9087         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9088         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9089         return (uint64_t)ret_conv;
9090 }
9091
9092 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
9093         LDKSecretKey o_ref;
9094         CHECK(o->arr_len == 32);
9095         memcpy(o_ref.bytes, o->elems, 32);
9096         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9097         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9098         return (uint64_t)ret_conv;
9099 }
9100
9101 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
9102         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9103         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9104         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9105         return (uint64_t)ret_conv;
9106 }
9107
9108 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
9109         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
9110         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
9111         return ret_val;
9112 }
9113
9114 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
9115         if ((_res & 1) != 0) return;
9116         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9117         CHECK_ACCESS(_res_ptr);
9118         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
9119         FREE((void*)_res);
9120         CResult_SecretKeyErrorZ_free(_res_conv);
9121 }
9122
9123 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
9124         LDKPublicKey o_ref;
9125         CHECK(o->arr_len == 33);
9126         memcpy(o_ref.compressed_form, o->elems, 33);
9127         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9128         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9129         return (uint64_t)ret_conv;
9130 }
9131
9132 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
9133         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9134         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9135         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9136         return (uint64_t)ret_conv;
9137 }
9138
9139 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
9140         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
9141         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
9142         return ret_val;
9143 }
9144
9145 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
9146         if ((_res & 1) != 0) return;
9147         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9148         CHECK_ACCESS(_res_ptr);
9149         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
9150         FREE((void*)_res);
9151         CResult_PublicKeyErrorZ_free(_res_conv);
9152 }
9153
9154 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
9155         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9156         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
9157         return (uint64_t)ret_conv;
9158 }
9159 int64_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
9160         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
9161         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
9162         return ret_val;
9163 }
9164
9165 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
9166         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9167         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9168         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9169         return (uint64_t)ret_conv;
9170 }
9171
9172 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
9173         LDKTxCreationKeys o_conv;
9174         o_conv.inner = (void*)(o & (~1));
9175         o_conv.is_owned = (o & 1) || (o == 0);
9176         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9177         o_conv = TxCreationKeys_clone(&o_conv);
9178         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9179         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9180         return (uint64_t)ret_conv;
9181 }
9182
9183 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
9184         LDKDecodeError e_conv;
9185         e_conv.inner = (void*)(e & (~1));
9186         e_conv.is_owned = (e & 1) || (e == 0);
9187         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9188         e_conv = DecodeError_clone(&e_conv);
9189         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9190         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9191         return (uint64_t)ret_conv;
9192 }
9193
9194 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
9195         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
9196         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
9197         return ret_val;
9198 }
9199
9200 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
9201         if ((_res & 1) != 0) return;
9202         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9203         CHECK_ACCESS(_res_ptr);
9204         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
9205         FREE((void*)_res);
9206         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9207 }
9208
9209 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
9210         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9211         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
9212         return (uint64_t)ret_conv;
9213 }
9214 int64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9215         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
9216         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
9217         return ret_val;
9218 }
9219
9220 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
9221         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9222         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9223         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9224         return (uint64_t)ret_conv;
9225 }
9226
9227 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
9228         LDKChannelPublicKeys o_conv;
9229         o_conv.inner = (void*)(o & (~1));
9230         o_conv.is_owned = (o & 1) || (o == 0);
9231         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9232         o_conv = ChannelPublicKeys_clone(&o_conv);
9233         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9234         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9235         return (uint64_t)ret_conv;
9236 }
9237
9238 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
9239         LDKDecodeError e_conv;
9240         e_conv.inner = (void*)(e & (~1));
9241         e_conv.is_owned = (e & 1) || (e == 0);
9242         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9243         e_conv = DecodeError_clone(&e_conv);
9244         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9245         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9246         return (uint64_t)ret_conv;
9247 }
9248
9249 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
9250         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
9251         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
9252         return ret_val;
9253 }
9254
9255 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
9256         if ((_res & 1) != 0) return;
9257         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9258         CHECK_ACCESS(_res_ptr);
9259         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
9260         FREE((void*)_res);
9261         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9262 }
9263
9264 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
9265         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9266         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
9267         return (uint64_t)ret_conv;
9268 }
9269 int64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9270         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
9271         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
9272         return ret_val;
9273 }
9274
9275 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
9276         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9277         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9278         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9279         return (uint64_t)ret_conv;
9280 }
9281
9282 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
9283         LDKTxCreationKeys o_conv;
9284         o_conv.inner = (void*)(o & (~1));
9285         o_conv.is_owned = (o & 1) || (o == 0);
9286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9287         o_conv = TxCreationKeys_clone(&o_conv);
9288         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9289         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9290         return (uint64_t)ret_conv;
9291 }
9292
9293 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
9294         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9295         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9296         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9297         return (uint64_t)ret_conv;
9298 }
9299
9300 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
9301         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
9302         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
9303         return ret_val;
9304 }
9305
9306 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
9307         if ((_res & 1) != 0) return;
9308         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9309         CHECK_ACCESS(_res_ptr);
9310         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
9311         FREE((void*)_res);
9312         CResult_TxCreationKeysErrorZ_free(_res_conv);
9313 }
9314
9315 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
9316         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9317         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
9318         return (uint64_t)ret_conv;
9319 }
9320 int64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
9321         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
9322         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
9323         return ret_val;
9324 }
9325
9326 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
9327         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9328         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9329         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9330         return (uint64_t)ret_conv;
9331 }
9332
9333 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
9334         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9335         *ret_copy = COption_u32Z_some(o);
9336         uint64_t ret_ref = (uint64_t)ret_copy;
9337         return ret_ref;
9338 }
9339
9340 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
9341         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9342         *ret_copy = COption_u32Z_none();
9343         uint64_t ret_ref = (uint64_t)ret_copy;
9344         return ret_ref;
9345 }
9346
9347 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
9348         if ((_res & 1) != 0) return;
9349         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9350         CHECK_ACCESS(_res_ptr);
9351         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
9352         FREE((void*)_res);
9353         COption_u32Z_free(_res_conv);
9354 }
9355
9356 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
9357         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9358         *ret_copy = COption_u32Z_clone(arg);
9359 uint64_t ret_ref = (uint64_t)ret_copy;
9360         return ret_ref;
9361 }
9362 int64_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
9363         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
9364         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
9365         return ret_val;
9366 }
9367
9368 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
9369         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9370         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9371         *ret_copy = COption_u32Z_clone(orig_conv);
9372         uint64_t ret_ref = (uint64_t)ret_copy;
9373         return ret_ref;
9374 }
9375
9376 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
9377         LDKHTLCOutputInCommitment o_conv;
9378         o_conv.inner = (void*)(o & (~1));
9379         o_conv.is_owned = (o & 1) || (o == 0);
9380         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9381         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9382         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9383         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9384         return (uint64_t)ret_conv;
9385 }
9386
9387 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
9388         LDKDecodeError e_conv;
9389         e_conv.inner = (void*)(e & (~1));
9390         e_conv.is_owned = (e & 1) || (e == 0);
9391         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9392         e_conv = DecodeError_clone(&e_conv);
9393         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9394         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9395         return (uint64_t)ret_conv;
9396 }
9397
9398 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
9399         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
9400         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
9401         return ret_val;
9402 }
9403
9404 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
9405         if ((_res & 1) != 0) return;
9406         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9407         CHECK_ACCESS(_res_ptr);
9408         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
9409         FREE((void*)_res);
9410         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9411 }
9412
9413 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
9414         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9415         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
9416         return (uint64_t)ret_conv;
9417 }
9418 int64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
9419         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
9420         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
9421         return ret_val;
9422 }
9423
9424 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
9425         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9426         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9427         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9428         return (uint64_t)ret_conv;
9429 }
9430
9431 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
9432         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
9433         return ret_conv;
9434 }
9435
9436 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
9437         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
9438         return ret_conv;
9439 }
9440
9441 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
9442         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
9443         COption_NoneZ_free(_res_conv);
9444 }
9445
9446 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9447         LDKCounterpartyChannelTransactionParameters o_conv;
9448         o_conv.inner = (void*)(o & (~1));
9449         o_conv.is_owned = (o & 1) || (o == 0);
9450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9451         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9452         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9453         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9454         return (uint64_t)ret_conv;
9455 }
9456
9457 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9458         LDKDecodeError e_conv;
9459         e_conv.inner = (void*)(e & (~1));
9460         e_conv.is_owned = (e & 1) || (e == 0);
9461         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9462         e_conv = DecodeError_clone(&e_conv);
9463         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9464         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9465         return (uint64_t)ret_conv;
9466 }
9467
9468 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9469         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9470         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9471         return ret_val;
9472 }
9473
9474 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9475         if ((_res & 1) != 0) return;
9476         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9477         CHECK_ACCESS(_res_ptr);
9478         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9479         FREE((void*)_res);
9480         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9481 }
9482
9483 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9484         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9485         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
9486         return (uint64_t)ret_conv;
9487 }
9488 int64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9489         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9490         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9491         return ret_val;
9492 }
9493
9494 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9495         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9496         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9497         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9498         return (uint64_t)ret_conv;
9499 }
9500
9501 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9502         LDKChannelTransactionParameters o_conv;
9503         o_conv.inner = (void*)(o & (~1));
9504         o_conv.is_owned = (o & 1) || (o == 0);
9505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9506         o_conv = ChannelTransactionParameters_clone(&o_conv);
9507         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9508         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9509         return (uint64_t)ret_conv;
9510 }
9511
9512 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9513         LDKDecodeError e_conv;
9514         e_conv.inner = (void*)(e & (~1));
9515         e_conv.is_owned = (e & 1) || (e == 0);
9516         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9517         e_conv = DecodeError_clone(&e_conv);
9518         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9519         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9520         return (uint64_t)ret_conv;
9521 }
9522
9523 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9524         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9525         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9526         return ret_val;
9527 }
9528
9529 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9530         if ((_res & 1) != 0) return;
9531         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9532         CHECK_ACCESS(_res_ptr);
9533         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9534         FREE((void*)_res);
9535         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9536 }
9537
9538 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9539         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9540         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
9541         return (uint64_t)ret_conv;
9542 }
9543 int64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9544         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9545         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9546         return ret_val;
9547 }
9548
9549 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9550         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9551         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9552         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9553         return (uint64_t)ret_conv;
9554 }
9555
9556 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
9557         LDKCVec_SignatureZ _res_constr;
9558         _res_constr.datalen = _res->arr_len;
9559         if (_res_constr.datalen > 0)
9560                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9561         else
9562                 _res_constr.data = NULL;
9563         int8_tArray* _res_vals = (void*) _res->elems;
9564         for (size_t m = 0; m < _res_constr.datalen; m++) {
9565                 int8_tArray _res_conv_12 = _res_vals[m];
9566                 LDKSignature _res_conv_12_ref;
9567                 CHECK(_res_conv_12->arr_len == 64);
9568                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64);
9569                 _res_constr.data[m] = _res_conv_12_ref;
9570         }
9571         CVec_SignatureZ_free(_res_constr);
9572 }
9573
9574 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9575         LDKHolderCommitmentTransaction o_conv;
9576         o_conv.inner = (void*)(o & (~1));
9577         o_conv.is_owned = (o & 1) || (o == 0);
9578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9579         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9580         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9581         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9582         return (uint64_t)ret_conv;
9583 }
9584
9585 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9586         LDKDecodeError e_conv;
9587         e_conv.inner = (void*)(e & (~1));
9588         e_conv.is_owned = (e & 1) || (e == 0);
9589         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9590         e_conv = DecodeError_clone(&e_conv);
9591         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9592         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9593         return (uint64_t)ret_conv;
9594 }
9595
9596 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9597         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
9598         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9599         return ret_val;
9600 }
9601
9602 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9603         if ((_res & 1) != 0) return;
9604         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9605         CHECK_ACCESS(_res_ptr);
9606         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9607         FREE((void*)_res);
9608         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9609 }
9610
9611 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9612         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9613         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
9614         return (uint64_t)ret_conv;
9615 }
9616 int64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9617         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9618         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9619         return ret_val;
9620 }
9621
9622 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9623         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9624         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9625         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9626         return (uint64_t)ret_conv;
9627 }
9628
9629 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9630         LDKBuiltCommitmentTransaction o_conv;
9631         o_conv.inner = (void*)(o & (~1));
9632         o_conv.is_owned = (o & 1) || (o == 0);
9633         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9634         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9635         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9636         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9637         return (uint64_t)ret_conv;
9638 }
9639
9640 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9641         LDKDecodeError e_conv;
9642         e_conv.inner = (void*)(e & (~1));
9643         e_conv.is_owned = (e & 1) || (e == 0);
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9645         e_conv = DecodeError_clone(&e_conv);
9646         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9647         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9648         return (uint64_t)ret_conv;
9649 }
9650
9651 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9652         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
9653         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9654         return ret_val;
9655 }
9656
9657 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9658         if ((_res & 1) != 0) return;
9659         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9660         CHECK_ACCESS(_res_ptr);
9661         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9662         FREE((void*)_res);
9663         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9664 }
9665
9666 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9667         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9668         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
9669         return (uint64_t)ret_conv;
9670 }
9671 int64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9672         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9673         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9674         return ret_val;
9675 }
9676
9677 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9678         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9679         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9680         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9681         return (uint64_t)ret_conv;
9682 }
9683
9684 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
9685         LDKTrustedClosingTransaction o_conv;
9686         o_conv.inner = (void*)(o & (~1));
9687         o_conv.is_owned = (o & 1) || (o == 0);
9688         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9689         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
9690         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9691         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
9692         return (uint64_t)ret_conv;
9693 }
9694
9695 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
9696         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9697         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
9698         return (uint64_t)ret_conv;
9699 }
9700
9701 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
9702         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
9703         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
9704         return ret_val;
9705 }
9706
9707 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
9708         if ((_res & 1) != 0) return;
9709         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9710         CHECK_ACCESS(_res_ptr);
9711         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
9712         FREE((void*)_res);
9713         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
9714 }
9715
9716 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9717         LDKCommitmentTransaction o_conv;
9718         o_conv.inner = (void*)(o & (~1));
9719         o_conv.is_owned = (o & 1) || (o == 0);
9720         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9721         o_conv = CommitmentTransaction_clone(&o_conv);
9722         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9723         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9724         return (uint64_t)ret_conv;
9725 }
9726
9727 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9728         LDKDecodeError e_conv;
9729         e_conv.inner = (void*)(e & (~1));
9730         e_conv.is_owned = (e & 1) || (e == 0);
9731         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9732         e_conv = DecodeError_clone(&e_conv);
9733         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9734         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9735         return (uint64_t)ret_conv;
9736 }
9737
9738 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9739         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
9740         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9741         return ret_val;
9742 }
9743
9744 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9745         if ((_res & 1) != 0) return;
9746         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9747         CHECK_ACCESS(_res_ptr);
9748         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
9749         FREE((void*)_res);
9750         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9751 }
9752
9753 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9754         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9755         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
9756         return (uint64_t)ret_conv;
9757 }
9758 int64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9759         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
9760         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9761         return ret_val;
9762 }
9763
9764 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9765         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9766         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9767         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9768         return (uint64_t)ret_conv;
9769 }
9770
9771 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
9772         LDKTrustedCommitmentTransaction o_conv;
9773         o_conv.inner = (void*)(o & (~1));
9774         o_conv.is_owned = (o & 1) || (o == 0);
9775         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9776         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9777         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9778         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9779         return (uint64_t)ret_conv;
9780 }
9781
9782 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
9783         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9784         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9785         return (uint64_t)ret_conv;
9786 }
9787
9788 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
9789         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
9790         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
9791         return ret_val;
9792 }
9793
9794 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
9795         if ((_res & 1) != 0) return;
9796         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9797         CHECK_ACCESS(_res_ptr);
9798         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
9799         FREE((void*)_res);
9800         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9801 }
9802
9803 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
9804         LDKCVec_SignatureZ o_constr;
9805         o_constr.datalen = o->arr_len;
9806         if (o_constr.datalen > 0)
9807                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9808         else
9809                 o_constr.data = NULL;
9810         int8_tArray* o_vals = (void*) o->elems;
9811         for (size_t m = 0; m < o_constr.datalen; m++) {
9812                 int8_tArray o_conv_12 = o_vals[m];
9813                 LDKSignature o_conv_12_ref;
9814                 CHECK(o_conv_12->arr_len == 64);
9815                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64);
9816                 o_constr.data[m] = o_conv_12_ref;
9817         }
9818         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9819         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9820         return (uint64_t)ret_conv;
9821 }
9822
9823 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
9824         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9825         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9826         return (uint64_t)ret_conv;
9827 }
9828
9829 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
9830         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
9831         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
9832         return ret_val;
9833 }
9834
9835 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
9836         if ((_res & 1) != 0) return;
9837         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9838         CHECK_ACCESS(_res_ptr);
9839         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
9840         FREE((void*)_res);
9841         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9842 }
9843
9844 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
9845         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9846         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
9847         return (uint64_t)ret_conv;
9848 }
9849 int64_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
9850         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
9851         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
9852         return ret_val;
9853 }
9854
9855 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
9856         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9857         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9858         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9859         return (uint64_t)ret_conv;
9860 }
9861
9862 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
9863         LDKShutdownScript o_conv;
9864         o_conv.inner = (void*)(o & (~1));
9865         o_conv.is_owned = (o & 1) || (o == 0);
9866         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9867         o_conv = ShutdownScript_clone(&o_conv);
9868         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9869         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9870         return (uint64_t)ret_conv;
9871 }
9872
9873 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
9874         LDKDecodeError e_conv;
9875         e_conv.inner = (void*)(e & (~1));
9876         e_conv.is_owned = (e & 1) || (e == 0);
9877         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9878         e_conv = DecodeError_clone(&e_conv);
9879         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9880         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9881         return (uint64_t)ret_conv;
9882 }
9883
9884 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
9885         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
9886         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
9887         return ret_val;
9888 }
9889
9890 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
9891         if ((_res & 1) != 0) return;
9892         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9893         CHECK_ACCESS(_res_ptr);
9894         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
9895         FREE((void*)_res);
9896         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9897 }
9898
9899 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
9900         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9901         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
9902         return (uint64_t)ret_conv;
9903 }
9904 int64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
9905         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
9906         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
9907         return ret_val;
9908 }
9909
9910 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
9911         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9912         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9913         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9914         return (uint64_t)ret_conv;
9915 }
9916
9917 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
9918         LDKShutdownScript o_conv;
9919         o_conv.inner = (void*)(o & (~1));
9920         o_conv.is_owned = (o & 1) || (o == 0);
9921         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9922         o_conv = ShutdownScript_clone(&o_conv);
9923         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9924         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9925         return (uint64_t)ret_conv;
9926 }
9927
9928 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
9929         LDKInvalidShutdownScript e_conv;
9930         e_conv.inner = (void*)(e & (~1));
9931         e_conv.is_owned = (e & 1) || (e == 0);
9932         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9933         e_conv = InvalidShutdownScript_clone(&e_conv);
9934         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9935         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9936         return (uint64_t)ret_conv;
9937 }
9938
9939 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
9940         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
9941         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
9942         return ret_val;
9943 }
9944
9945 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
9946         if ((_res & 1) != 0) return;
9947         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9948         CHECK_ACCESS(_res_ptr);
9949         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
9950         FREE((void*)_res);
9951         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9952 }
9953
9954 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
9955         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9956         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
9957         return (uint64_t)ret_conv;
9958 }
9959 int64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
9960         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
9961         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
9962         return ret_val;
9963 }
9964
9965 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
9966         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
9967         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9968         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
9969         return (uint64_t)ret_conv;
9970 }
9971
9972 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
9973         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9974         CHECK_ACCESS(o_ptr);
9975         LDKType o_conv = *(LDKType*)(o_ptr);
9976         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9977         *ret_copy = COption_TypeZ_some(o_conv);
9978         uint64_t ret_ref = (uint64_t)ret_copy;
9979         return ret_ref;
9980 }
9981
9982 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
9983         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9984         *ret_copy = COption_TypeZ_none();
9985         uint64_t ret_ref = (uint64_t)ret_copy;
9986         return ret_ref;
9987 }
9988
9989 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
9990         if ((_res & 1) != 0) return;
9991         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9992         CHECK_ACCESS(_res_ptr);
9993         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
9994         FREE((void*)_res);
9995         COption_TypeZ_free(_res_conv);
9996 }
9997
9998 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
9999         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10000         *ret_copy = COption_TypeZ_clone(arg);
10001 uint64_t ret_ref = (uint64_t)ret_copy;
10002         return ret_ref;
10003 }
10004 int64_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
10005         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
10006         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
10007         return ret_val;
10008 }
10009
10010 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
10011         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
10012         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10013         *ret_copy = COption_TypeZ_clone(orig_conv);
10014         uint64_t ret_ref = (uint64_t)ret_copy;
10015         return ret_ref;
10016 }
10017
10018 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
10019         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10020         CHECK_ACCESS(o_ptr);
10021         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
10022         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
10023         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10024         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
10025         return (uint64_t)ret_conv;
10026 }
10027
10028 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
10029         LDKDecodeError e_conv;
10030         e_conv.inner = (void*)(e & (~1));
10031         e_conv.is_owned = (e & 1) || (e == 0);
10032         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10033         e_conv = DecodeError_clone(&e_conv);
10034         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10035         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
10036         return (uint64_t)ret_conv;
10037 }
10038
10039 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
10040         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
10041         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
10042         return ret_val;
10043 }
10044
10045 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
10046         if ((_res & 1) != 0) return;
10047         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10048         CHECK_ACCESS(_res_ptr);
10049         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
10050         FREE((void*)_res);
10051         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
10052 }
10053
10054 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
10055         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10056         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
10057         return (uint64_t)ret_conv;
10058 }
10059 int64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
10060         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
10061         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
10062         return ret_val;
10063 }
10064
10065 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
10066         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
10067         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10068         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
10069         return (uint64_t)ret_conv;
10070 }
10071
10072 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
10073         LDKStr o_conv = str_ref_to_owned_c(o);
10074         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10075         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10076         return (uint64_t)ret_conv;
10077 }
10078
10079 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
10080         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10081         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10082         *ret_conv = CResult_StringErrorZ_err(e_conv);
10083         return (uint64_t)ret_conv;
10084 }
10085
10086 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
10087         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
10088         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
10089         return ret_val;
10090 }
10091
10092 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
10093         if ((_res & 1) != 0) return;
10094         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10095         CHECK_ACCESS(_res_ptr);
10096         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
10097         FREE((void*)_res);
10098         CResult_StringErrorZ_free(_res_conv);
10099 }
10100
10101 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
10102         LDKChannelMonitorUpdate o_conv;
10103         o_conv.inner = (void*)(o & (~1));
10104         o_conv.is_owned = (o & 1) || (o == 0);
10105         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10106         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10107         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10108         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10109         return (uint64_t)ret_conv;
10110 }
10111
10112 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
10113         LDKDecodeError e_conv;
10114         e_conv.inner = (void*)(e & (~1));
10115         e_conv.is_owned = (e & 1) || (e == 0);
10116         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10117         e_conv = DecodeError_clone(&e_conv);
10118         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10119         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10120         return (uint64_t)ret_conv;
10121 }
10122
10123 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
10124         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
10125         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
10126         return ret_val;
10127 }
10128
10129 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
10130         if ((_res & 1) != 0) return;
10131         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10132         CHECK_ACCESS(_res_ptr);
10133         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
10134         FREE((void*)_res);
10135         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10136 }
10137
10138 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
10139         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10140         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
10141         return (uint64_t)ret_conv;
10142 }
10143 int64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10144         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
10145         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
10146         return ret_val;
10147 }
10148
10149 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
10150         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10151         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10152         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10153         return (uint64_t)ret_conv;
10154 }
10155
10156 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
10157         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10158         CHECK_ACCESS(o_ptr);
10159         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
10160         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
10161         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10162         *ret_copy = COption_MonitorEventZ_some(o_conv);
10163         uint64_t ret_ref = (uint64_t)ret_copy;
10164         return ret_ref;
10165 }
10166
10167 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
10168         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10169         *ret_copy = COption_MonitorEventZ_none();
10170         uint64_t ret_ref = (uint64_t)ret_copy;
10171         return ret_ref;
10172 }
10173
10174 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
10175         if ((_res & 1) != 0) return;
10176         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10177         CHECK_ACCESS(_res_ptr);
10178         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
10179         FREE((void*)_res);
10180         COption_MonitorEventZ_free(_res_conv);
10181 }
10182
10183 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
10184         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10185         *ret_copy = COption_MonitorEventZ_clone(arg);
10186 uint64_t ret_ref = (uint64_t)ret_copy;
10187         return ret_ref;
10188 }
10189 int64_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
10190         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
10191         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
10192         return ret_val;
10193 }
10194
10195 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
10196         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
10197         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10198         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
10199         uint64_t ret_ref = (uint64_t)ret_copy;
10200         return ret_ref;
10201 }
10202
10203 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
10204         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10205         CHECK_ACCESS(o_ptr);
10206         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
10207         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
10208         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10209         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
10210         return (uint64_t)ret_conv;
10211 }
10212
10213 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
10214         LDKDecodeError e_conv;
10215         e_conv.inner = (void*)(e & (~1));
10216         e_conv.is_owned = (e & 1) || (e == 0);
10217         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10218         e_conv = DecodeError_clone(&e_conv);
10219         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10220         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
10221         return (uint64_t)ret_conv;
10222 }
10223
10224 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
10225         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
10226         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
10227         return ret_val;
10228 }
10229
10230 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
10231         if ((_res & 1) != 0) return;
10232         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10233         CHECK_ACCESS(_res_ptr);
10234         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
10235         FREE((void*)_res);
10236         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
10237 }
10238
10239 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
10240         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10241         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
10242         return (uint64_t)ret_conv;
10243 }
10244 int64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
10245         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
10246         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
10247         return ret_val;
10248 }
10249
10250 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
10251         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
10252         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10253         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
10254         return (uint64_t)ret_conv;
10255 }
10256
10257 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
10258         LDKHTLCUpdate o_conv;
10259         o_conv.inner = (void*)(o & (~1));
10260         o_conv.is_owned = (o & 1) || (o == 0);
10261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10262         o_conv = HTLCUpdate_clone(&o_conv);
10263         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10264         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10265         return (uint64_t)ret_conv;
10266 }
10267
10268 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
10269         LDKDecodeError e_conv;
10270         e_conv.inner = (void*)(e & (~1));
10271         e_conv.is_owned = (e & 1) || (e == 0);
10272         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10273         e_conv = DecodeError_clone(&e_conv);
10274         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10275         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10276         return (uint64_t)ret_conv;
10277 }
10278
10279 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
10280         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
10281         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
10282         return ret_val;
10283 }
10284
10285 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
10286         if ((_res & 1) != 0) return;
10287         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10288         CHECK_ACCESS(_res_ptr);
10289         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
10290         FREE((void*)_res);
10291         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10292 }
10293
10294 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
10295         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10296         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
10297         return (uint64_t)ret_conv;
10298 }
10299 int64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10300         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
10301         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
10302         return ret_val;
10303 }
10304
10305 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
10306         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10307         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10308         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10309         return (uint64_t)ret_conv;
10310 }
10311
10312 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10313         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10314         *ret_conv = CResult_NoneNoneZ_ok();
10315         return (uint64_t)ret_conv;
10316 }
10317
10318 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10319         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10320         *ret_conv = CResult_NoneNoneZ_err();
10321         return (uint64_t)ret_conv;
10322 }
10323
10324 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10325         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10326         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10327         return ret_val;
10328 }
10329
10330 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10331         if ((_res & 1) != 0) return;
10332         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10333         CHECK_ACCESS(_res_ptr);
10334         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10335         FREE((void*)_res);
10336         CResult_NoneNoneZ_free(_res_conv);
10337 }
10338
10339 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10340         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10341         *ret_conv = CResult_NoneNoneZ_clone(arg);
10342         return (uint64_t)ret_conv;
10343 }
10344 int64_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10345         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10346         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10347         return ret_val;
10348 }
10349
10350 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10351         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10352         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10353         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10354         return (uint64_t)ret_conv;
10355 }
10356
10357 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
10358         LDKOutPoint a_conv;
10359         a_conv.inner = (void*)(a & (~1));
10360         a_conv.is_owned = (a & 1) || (a == 0);
10361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
10362         a_conv = OutPoint_clone(&a_conv);
10363         LDKCVec_u8Z b_ref;
10364         b_ref.datalen = b->arr_len;
10365         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10366         memcpy(b_ref.data, b->elems, b_ref.datalen);
10367         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10368         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10369         return ((uint64_t)ret_conv);
10370 }
10371
10372 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
10373         if ((_res & 1) != 0) return;
10374         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10375         CHECK_ACCESS(_res_ptr);
10376         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
10377         FREE((void*)_res);
10378         C2Tuple_OutPointScriptZ_free(_res_conv);
10379 }
10380
10381 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
10382         LDKCVec_u8Z b_ref;
10383         b_ref.datalen = b->arr_len;
10384         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10385         memcpy(b_ref.data, b->elems, b_ref.datalen);
10386         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10387         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
10388         return ((uint64_t)ret_conv);
10389 }
10390
10391 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
10392         if ((_res & 1) != 0) return;
10393         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10394         CHECK_ACCESS(_res_ptr);
10395         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
10396         FREE((void*)_res);
10397         C2Tuple_u32ScriptZ_free(_res_conv);
10398 }
10399
10400 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
10401         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10402         _res_constr.datalen = _res->arr_len;
10403         if (_res_constr.datalen > 0)
10404                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10405         else
10406                 _res_constr.data = NULL;
10407         uint32_t* _res_vals = _res->elems;
10408         for (size_t v = 0; v < _res_constr.datalen; v++) {
10409                 uint32_t _res_conv_21 = _res_vals[v];
10410                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
10411                 CHECK_ACCESS(_res_conv_21_ptr);
10412                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
10413                 FREE((void*)_res_conv_21);
10414                 _res_constr.data[v] = _res_conv_21_conv;
10415         }
10416         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10417 }
10418
10419 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
10420         LDKThirtyTwoBytes a_ref;
10421         CHECK(a->arr_len == 32);
10422         memcpy(a_ref.data, a->elems, 32);
10423         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10424         b_constr.datalen = b->arr_len;
10425         if (b_constr.datalen > 0)
10426                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10427         else
10428                 b_constr.data = NULL;
10429         uint32_t* b_vals = b->elems;
10430         for (size_t v = 0; v < b_constr.datalen; v++) {
10431                 uint32_t b_conv_21 = b_vals[v];
10432                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
10433                 CHECK_ACCESS(b_conv_21_ptr);
10434                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
10435                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
10436                 b_constr.data[v] = b_conv_21_conv;
10437         }
10438         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10439         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10440         return ((uint64_t)ret_conv);
10441 }
10442
10443 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
10444         if ((_res & 1) != 0) return;
10445         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10446         CHECK_ACCESS(_res_ptr);
10447         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
10448         FREE((void*)_res);
10449         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10450 }
10451
10452 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
10453         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10454         _res_constr.datalen = _res->arr_len;
10455         if (_res_constr.datalen > 0)
10456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10457         else
10458                 _res_constr.data = NULL;
10459         uint32_t* _res_vals = _res->elems;
10460         for (size_t o = 0; o < _res_constr.datalen; o++) {
10461                 uint32_t _res_conv_40 = _res_vals[o];
10462                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
10463                 CHECK_ACCESS(_res_conv_40_ptr);
10464                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
10465                 FREE((void*)_res_conv_40);
10466                 _res_constr.data[o] = _res_conv_40_conv;
10467         }
10468         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
10469 }
10470
10471 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
10472         LDKCVec_MonitorEventZ _res_constr;
10473         _res_constr.datalen = _res->arr_len;
10474         if (_res_constr.datalen > 0)
10475                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
10476         else
10477                 _res_constr.data = NULL;
10478         uint32_t* _res_vals = _res->elems;
10479         for (size_t o = 0; o < _res_constr.datalen; o++) {
10480                 uint32_t _res_conv_14 = _res_vals[o];
10481                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
10482                 CHECK_ACCESS(_res_conv_14_ptr);
10483                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
10484                 FREE((void*)_res_conv_14);
10485                 _res_constr.data[o] = _res_conv_14_conv;
10486         }
10487         CVec_MonitorEventZ_free(_res_constr);
10488 }
10489
10490 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
10491         LDKCVec_EventZ _res_constr;
10492         _res_constr.datalen = _res->arr_len;
10493         if (_res_constr.datalen > 0)
10494                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
10495         else
10496                 _res_constr.data = NULL;
10497         uint32_t* _res_vals = _res->elems;
10498         for (size_t h = 0; h < _res_constr.datalen; h++) {
10499                 uint32_t _res_conv_7 = _res_vals[h];
10500                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
10501                 CHECK_ACCESS(_res_conv_7_ptr);
10502                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
10503                 FREE((void*)_res_conv_7);
10504                 _res_constr.data[h] = _res_conv_7_conv;
10505         }
10506         CVec_EventZ_free(_res_constr);
10507 }
10508
10509 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
10510         LDKCVec_TransactionZ _res_constr;
10511         _res_constr.datalen = _res->arr_len;
10512         if (_res_constr.datalen > 0)
10513                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
10514         else
10515                 _res_constr.data = NULL;
10516         int8_tArray* _res_vals = (void*) _res->elems;
10517         for (size_t m = 0; m < _res_constr.datalen; m++) {
10518                 int8_tArray _res_conv_12 = _res_vals[m];
10519                 LDKTransaction _res_conv_12_ref;
10520                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
10521                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
10522                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen);
10523                 _res_conv_12_ref.data_is_owned = true;
10524                 _res_constr.data[m] = _res_conv_12_ref;
10525         }
10526         CVec_TransactionZ_free(_res_constr);
10527 }
10528
10529 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
10530         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10531         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
10532         return ((uint64_t)ret_conv);
10533 }
10534 int64_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
10535         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
10536         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
10537         return ret_val;
10538 }
10539
10540 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
10541         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
10542         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10543         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
10544         return ((uint64_t)ret_conv);
10545 }
10546
10547 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
10548         LDKTransaction b_ref;
10549         b_ref.datalen = b->arr_len;
10550         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
10551         memcpy(b_ref.data, b->elems, b_ref.datalen);
10552         b_ref.data_is_owned = true;
10553         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10554         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
10555         return ((uint64_t)ret_conv);
10556 }
10557
10558 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
10559         if ((_res & 1) != 0) return;
10560         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10561         CHECK_ACCESS(_res_ptr);
10562         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
10563         FREE((void*)_res);
10564         C2Tuple_usizeTransactionZ_free(_res_conv);
10565 }
10566
10567 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
10568         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
10569         _res_constr.datalen = _res->arr_len;
10570         if (_res_constr.datalen > 0)
10571                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10572         else
10573                 _res_constr.data = NULL;
10574         uint32_t* _res_vals = _res->elems;
10575         for (size_t c = 0; c < _res_constr.datalen; c++) {
10576                 uint32_t _res_conv_28 = _res_vals[c];
10577                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
10578                 CHECK_ACCESS(_res_conv_28_ptr);
10579                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
10580                 FREE((void*)_res_conv_28);
10581                 _res_constr.data[c] = _res_conv_28_conv;
10582         }
10583         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
10584 }
10585
10586 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
10587         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10588         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
10589         return ((uint64_t)ret_conv);
10590 }
10591 int64_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
10592         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
10593         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
10594         return ret_val;
10595 }
10596
10597 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
10598         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
10599         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10600         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
10601         return ((uint64_t)ret_conv);
10602 }
10603
10604 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
10605         void* b_ptr = (void*)(((uint64_t)b) & ~1);
10606         CHECK_ACCESS(b_ptr);
10607         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
10608         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
10609         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10610         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
10611         return ((uint64_t)ret_conv);
10612 }
10613
10614 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
10615         if ((_res & 1) != 0) return;
10616         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10617         CHECK_ACCESS(_res_ptr);
10618         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
10619         FREE((void*)_res);
10620         C2Tuple_u32TxOutZ_free(_res_conv);
10621 }
10622
10623 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
10624         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
10625         _res_constr.datalen = _res->arr_len;
10626         if (_res_constr.datalen > 0)
10627                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10628         else
10629                 _res_constr.data = NULL;
10630         uint32_t* _res_vals = _res->elems;
10631         for (size_t u = 0; u < _res_constr.datalen; u++) {
10632                 uint32_t _res_conv_20 = _res_vals[u];
10633                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
10634                 CHECK_ACCESS(_res_conv_20_ptr);
10635                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
10636                 FREE((void*)_res_conv_20);
10637                 _res_constr.data[u] = _res_conv_20_conv;
10638         }
10639         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
10640 }
10641
10642 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
10643         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10644         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
10645         return ((uint64_t)ret_conv);
10646 }
10647 int64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
10648         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
10649         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
10650         return ret_val;
10651 }
10652
10653 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
10654         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
10655         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10656         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
10657         return ((uint64_t)ret_conv);
10658 }
10659
10660 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
10661         LDKThirtyTwoBytes a_ref;
10662         CHECK(a->arr_len == 32);
10663         memcpy(a_ref.data, a->elems, 32);
10664         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
10665         b_constr.datalen = b->arr_len;
10666         if (b_constr.datalen > 0)
10667                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10668         else
10669                 b_constr.data = NULL;
10670         uint32_t* b_vals = b->elems;
10671         for (size_t u = 0; u < b_constr.datalen; u++) {
10672                 uint32_t b_conv_20 = b_vals[u];
10673                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
10674                 CHECK_ACCESS(b_conv_20_ptr);
10675                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
10676                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
10677                 b_constr.data[u] = b_conv_20_conv;
10678         }
10679         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10680         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
10681         return ((uint64_t)ret_conv);
10682 }
10683
10684 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
10685         if ((_res & 1) != 0) return;
10686         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10687         CHECK_ACCESS(_res_ptr);
10688         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
10689         FREE((void*)_res);
10690         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
10691 }
10692
10693 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
10694         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
10695         _res_constr.datalen = _res->arr_len;
10696         if (_res_constr.datalen > 0)
10697                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
10698         else
10699                 _res_constr.data = NULL;
10700         uint32_t* _res_vals = _res->elems;
10701         for (size_t n = 0; n < _res_constr.datalen; n++) {
10702                 uint32_t _res_conv_39 = _res_vals[n];
10703                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
10704                 CHECK_ACCESS(_res_conv_39_ptr);
10705                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
10706                 FREE((void*)_res_conv_39);
10707                 _res_constr.data[n] = _res_conv_39_conv;
10708         }
10709         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
10710 }
10711
10712 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
10713         LDKCVec_TxidZ _res_constr;
10714         _res_constr.datalen = _res->arr_len;
10715         if (_res_constr.datalen > 0)
10716                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10717         else
10718                 _res_constr.data = NULL;
10719         int8_tArray* _res_vals = (void*) _res->elems;
10720         for (size_t m = 0; m < _res_constr.datalen; m++) {
10721                 int8_tArray _res_conv_12 = _res_vals[m];
10722                 LDKThirtyTwoBytes _res_conv_12_ref;
10723                 CHECK(_res_conv_12->arr_len == 32);
10724                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32);
10725                 _res_constr.data[m] = _res_conv_12_ref;
10726         }
10727         CVec_TxidZ_free(_res_constr);
10728 }
10729
10730 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
10731         LDKCVec_BalanceZ _res_constr;
10732         _res_constr.datalen = _res->arr_len;
10733         if (_res_constr.datalen > 0)
10734                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
10735         else
10736                 _res_constr.data = NULL;
10737         uint32_t* _res_vals = _res->elems;
10738         for (size_t j = 0; j < _res_constr.datalen; j++) {
10739                 uint32_t _res_conv_9 = _res_vals[j];
10740                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
10741                 CHECK_ACCESS(_res_conv_9_ptr);
10742                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
10743                 FREE((void*)_res_conv_9);
10744                 _res_constr.data[j] = _res_conv_9_conv;
10745         }
10746         CVec_BalanceZ_free(_res_constr);
10747 }
10748
10749 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
10750         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10751         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
10752         return ((uint64_t)ret_conv);
10753 }
10754 int64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
10755         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
10756         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
10757         return ret_val;
10758 }
10759
10760 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
10761         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
10762         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10763         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
10764         return ((uint64_t)ret_conv);
10765 }
10766
10767 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
10768         LDKThirtyTwoBytes a_ref;
10769         CHECK(a->arr_len == 32);
10770         memcpy(a_ref.data, a->elems, 32);
10771         LDKChannelMonitor b_conv;
10772         b_conv.inner = (void*)(b & (~1));
10773         b_conv.is_owned = (b & 1) || (b == 0);
10774         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
10775         b_conv = ChannelMonitor_clone(&b_conv);
10776         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10777         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10778         return ((uint64_t)ret_conv);
10779 }
10780
10781 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
10782         if ((_res & 1) != 0) return;
10783         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10784         CHECK_ACCESS(_res_ptr);
10785         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
10786         FREE((void*)_res);
10787         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10788 }
10789
10790 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
10791         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10792         CHECK_ACCESS(o_ptr);
10793         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
10794         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
10795         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10796         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
10797         return (uint64_t)ret_conv;
10798 }
10799
10800 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
10801         LDKDecodeError e_conv;
10802         e_conv.inner = (void*)(e & (~1));
10803         e_conv.is_owned = (e & 1) || (e == 0);
10804         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10805         e_conv = DecodeError_clone(&e_conv);
10806         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10807         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
10808         return (uint64_t)ret_conv;
10809 }
10810
10811 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
10812         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
10813         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
10814         return ret_val;
10815 }
10816
10817 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
10818         if ((_res & 1) != 0) return;
10819         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10820         CHECK_ACCESS(_res_ptr);
10821         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
10822         FREE((void*)_res);
10823         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
10824 }
10825
10826 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
10827         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10828         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
10829         return (uint64_t)ret_conv;
10830 }
10831 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
10832         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
10833         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
10834         return ret_val;
10835 }
10836
10837 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
10838         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
10839         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10840         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
10841         return (uint64_t)ret_conv;
10842 }
10843
10844 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
10845         LDKRouteHop o_conv;
10846         o_conv.inner = (void*)(o & (~1));
10847         o_conv.is_owned = (o & 1) || (o == 0);
10848         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10849         o_conv = RouteHop_clone(&o_conv);
10850         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10851         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
10852         return (uint64_t)ret_conv;
10853 }
10854
10855 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
10856         LDKDecodeError e_conv;
10857         e_conv.inner = (void*)(e & (~1));
10858         e_conv.is_owned = (e & 1) || (e == 0);
10859         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10860         e_conv = DecodeError_clone(&e_conv);
10861         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10862         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
10863         return (uint64_t)ret_conv;
10864 }
10865
10866 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
10867         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
10868         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
10869         return ret_val;
10870 }
10871
10872 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
10873         if ((_res & 1) != 0) return;
10874         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10875         CHECK_ACCESS(_res_ptr);
10876         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
10877         FREE((void*)_res);
10878         CResult_RouteHopDecodeErrorZ_free(_res_conv);
10879 }
10880
10881 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
10882         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10883         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
10884         return (uint64_t)ret_conv;
10885 }
10886 int64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
10887         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
10888         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
10889         return ret_val;
10890 }
10891
10892 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
10893         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
10894         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10895         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
10896         return (uint64_t)ret_conv;
10897 }
10898
10899 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
10900         LDKCVec_RouteHopZ _res_constr;
10901         _res_constr.datalen = _res->arr_len;
10902         if (_res_constr.datalen > 0)
10903                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10904         else
10905                 _res_constr.data = NULL;
10906         uint32_t* _res_vals = _res->elems;
10907         for (size_t k = 0; k < _res_constr.datalen; k++) {
10908                 uint32_t _res_conv_10 = _res_vals[k];
10909                 LDKRouteHop _res_conv_10_conv;
10910                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
10911                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
10912                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
10913                 _res_constr.data[k] = _res_conv_10_conv;
10914         }
10915         CVec_RouteHopZ_free(_res_constr);
10916 }
10917
10918 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
10919         LDKCVec_CVec_RouteHopZZ _res_constr;
10920         _res_constr.datalen = _res->arr_len;
10921         if (_res_constr.datalen > 0)
10922                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
10923         else
10924                 _res_constr.data = NULL;
10925         uint32_tArray* _res_vals = (void*) _res->elems;
10926         for (size_t m = 0; m < _res_constr.datalen; m++) {
10927                 uint32_tArray _res_conv_12 = _res_vals[m];
10928                 LDKCVec_RouteHopZ _res_conv_12_constr;
10929                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
10930                 if (_res_conv_12_constr.datalen > 0)
10931                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10932                 else
10933                         _res_conv_12_constr.data = NULL;
10934                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
10935                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
10936                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
10937                         LDKRouteHop _res_conv_12_conv_10_conv;
10938                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
10939                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
10940                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
10941                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
10942                 }
10943                 _res_constr.data[m] = _res_conv_12_constr;
10944         }
10945         CVec_CVec_RouteHopZZ_free(_res_constr);
10946 }
10947
10948 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
10949         LDKRoute o_conv;
10950         o_conv.inner = (void*)(o & (~1));
10951         o_conv.is_owned = (o & 1) || (o == 0);
10952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10953         o_conv = Route_clone(&o_conv);
10954         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10955         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
10956         return (uint64_t)ret_conv;
10957 }
10958
10959 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
10960         LDKDecodeError e_conv;
10961         e_conv.inner = (void*)(e & (~1));
10962         e_conv.is_owned = (e & 1) || (e == 0);
10963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10964         e_conv = DecodeError_clone(&e_conv);
10965         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10966         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
10967         return (uint64_t)ret_conv;
10968 }
10969
10970 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
10971         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
10972         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
10973         return ret_val;
10974 }
10975
10976 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
10977         if ((_res & 1) != 0) return;
10978         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10979         CHECK_ACCESS(_res_ptr);
10980         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
10981         FREE((void*)_res);
10982         CResult_RouteDecodeErrorZ_free(_res_conv);
10983 }
10984
10985 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
10986         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10987         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
10988         return (uint64_t)ret_conv;
10989 }
10990 int64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
10991         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
10992         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
10993         return ret_val;
10994 }
10995
10996 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
10997         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
10998         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10999         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11000         return (uint64_t)ret_conv;
11001 }
11002
11003 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11004         LDKRouteParameters o_conv;
11005         o_conv.inner = (void*)(o & (~1));
11006         o_conv.is_owned = (o & 1) || (o == 0);
11007         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11008         o_conv = RouteParameters_clone(&o_conv);
11009         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11010         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11011         return (uint64_t)ret_conv;
11012 }
11013
11014 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11015         LDKDecodeError e_conv;
11016         e_conv.inner = (void*)(e & (~1));
11017         e_conv.is_owned = (e & 1) || (e == 0);
11018         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11019         e_conv = DecodeError_clone(&e_conv);
11020         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11021         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11022         return (uint64_t)ret_conv;
11023 }
11024
11025 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11026         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11027         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11028         return ret_val;
11029 }
11030
11031 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11032         if ((_res & 1) != 0) return;
11033         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11034         CHECK_ACCESS(_res_ptr);
11035         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11036         FREE((void*)_res);
11037         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11038 }
11039
11040 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11041         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11042         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11043         return (uint64_t)ret_conv;
11044 }
11045 int64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11046         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11047         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11048         return ret_val;
11049 }
11050
11051 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11052         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11053         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11054         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11055         return (uint64_t)ret_conv;
11056 }
11057
11058 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11059         LDKCVec_RouteHintZ _res_constr;
11060         _res_constr.datalen = _res->arr_len;
11061         if (_res_constr.datalen > 0)
11062                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11063         else
11064                 _res_constr.data = NULL;
11065         uint32_t* _res_vals = _res->elems;
11066         for (size_t l = 0; l < _res_constr.datalen; l++) {
11067                 uint32_t _res_conv_11 = _res_vals[l];
11068                 LDKRouteHint _res_conv_11_conv;
11069                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11070                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11072                 _res_constr.data[l] = _res_conv_11_conv;
11073         }
11074         CVec_RouteHintZ_free(_res_constr);
11075 }
11076
11077 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11078         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11079         *ret_copy = COption_u64Z_some(o);
11080         uint64_t ret_ref = (uint64_t)ret_copy;
11081         return ret_ref;
11082 }
11083
11084 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11085         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11086         *ret_copy = COption_u64Z_none();
11087         uint64_t ret_ref = (uint64_t)ret_copy;
11088         return ret_ref;
11089 }
11090
11091 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11092         if ((_res & 1) != 0) return;
11093         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11094         CHECK_ACCESS(_res_ptr);
11095         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11096         FREE((void*)_res);
11097         COption_u64Z_free(_res_conv);
11098 }
11099
11100 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11101         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11102         *ret_copy = COption_u64Z_clone(arg);
11103 uint64_t ret_ref = (uint64_t)ret_copy;
11104         return ret_ref;
11105 }
11106 int64_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11107         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11108         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11109         return ret_val;
11110 }
11111
11112 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11113         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11114         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11115         *ret_copy = COption_u64Z_clone(orig_conv);
11116         uint64_t ret_ref = (uint64_t)ret_copy;
11117         return ret_ref;
11118 }
11119
11120 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_ok"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
11121         LDKPayee o_conv;
11122         o_conv.inner = (void*)(o & (~1));
11123         o_conv.is_owned = (o & 1) || (o == 0);
11124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11125         o_conv = Payee_clone(&o_conv);
11126         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11127         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
11128         return (uint64_t)ret_conv;
11129 }
11130
11131 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_err"))) TS_CResult_PayeeDecodeErrorZ_err(uint32_t e) {
11132         LDKDecodeError e_conv;
11133         e_conv.inner = (void*)(e & (~1));
11134         e_conv.is_owned = (e & 1) || (e == 0);
11135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11136         e_conv = DecodeError_clone(&e_conv);
11137         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11138         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
11139         return (uint64_t)ret_conv;
11140 }
11141
11142 jboolean  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_is_ok"))) TS_CResult_PayeeDecodeErrorZ_is_ok(uint32_t o) {
11143         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
11144         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
11145         return ret_val;
11146 }
11147
11148 void  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_free"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
11149         if ((_res & 1) != 0) return;
11150         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11151         CHECK_ACCESS(_res_ptr);
11152         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
11153         FREE((void*)_res);
11154         CResult_PayeeDecodeErrorZ_free(_res_conv);
11155 }
11156
11157 static inline uintptr_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
11158         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11159         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
11160         return (uint64_t)ret_conv;
11161 }
11162 int64_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone_ptr"))) TS_CResult_PayeeDecodeErrorZ_clone_ptr(uint32_t arg) {
11163         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
11164         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
11165         return ret_val;
11166 }
11167
11168 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
11169         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
11170         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11171         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
11172         return (uint64_t)ret_conv;
11173 }
11174
11175 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11176         LDKCVec_RouteHintHopZ _res_constr;
11177         _res_constr.datalen = _res->arr_len;
11178         if (_res_constr.datalen > 0)
11179                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11180         else
11181                 _res_constr.data = NULL;
11182         uint32_t* _res_vals = _res->elems;
11183         for (size_t o = 0; o < _res_constr.datalen; o++) {
11184                 uint32_t _res_conv_14 = _res_vals[o];
11185                 LDKRouteHintHop _res_conv_14_conv;
11186                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11187                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11188                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11189                 _res_constr.data[o] = _res_conv_14_conv;
11190         }
11191         CVec_RouteHintHopZ_free(_res_constr);
11192 }
11193
11194 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11195         LDKRouteHint o_conv;
11196         o_conv.inner = (void*)(o & (~1));
11197         o_conv.is_owned = (o & 1) || (o == 0);
11198         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11199         o_conv = RouteHint_clone(&o_conv);
11200         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11201         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11202         return (uint64_t)ret_conv;
11203 }
11204
11205 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11206         LDKDecodeError e_conv;
11207         e_conv.inner = (void*)(e & (~1));
11208         e_conv.is_owned = (e & 1) || (e == 0);
11209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11210         e_conv = DecodeError_clone(&e_conv);
11211         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11212         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11213         return (uint64_t)ret_conv;
11214 }
11215
11216 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11217         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11218         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11219         return ret_val;
11220 }
11221
11222 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11223         if ((_res & 1) != 0) return;
11224         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11225         CHECK_ACCESS(_res_ptr);
11226         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11227         FREE((void*)_res);
11228         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11229 }
11230
11231 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11232         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11233         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11234         return (uint64_t)ret_conv;
11235 }
11236 int64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11237         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11238         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11239         return ret_val;
11240 }
11241
11242 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11243         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11244         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11245         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11246         return (uint64_t)ret_conv;
11247 }
11248
11249 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11250         LDKRouteHintHop o_conv;
11251         o_conv.inner = (void*)(o & (~1));
11252         o_conv.is_owned = (o & 1) || (o == 0);
11253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11254         o_conv = RouteHintHop_clone(&o_conv);
11255         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11256         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11257         return (uint64_t)ret_conv;
11258 }
11259
11260 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11261         LDKDecodeError e_conv;
11262         e_conv.inner = (void*)(e & (~1));
11263         e_conv.is_owned = (e & 1) || (e == 0);
11264         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11265         e_conv = DecodeError_clone(&e_conv);
11266         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11267         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11268         return (uint64_t)ret_conv;
11269 }
11270
11271 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11272         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11273         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11274         return ret_val;
11275 }
11276
11277 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11278         if ((_res & 1) != 0) return;
11279         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11280         CHECK_ACCESS(_res_ptr);
11281         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11282         FREE((void*)_res);
11283         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11284 }
11285
11286 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11287         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11288         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11289         return (uint64_t)ret_conv;
11290 }
11291 int64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11292         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11293         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11294         return ret_val;
11295 }
11296
11297 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11298         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11299         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11300         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11301         return (uint64_t)ret_conv;
11302 }
11303
11304 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11305         LDKCVec_ChannelDetailsZ _res_constr;
11306         _res_constr.datalen = _res->arr_len;
11307         if (_res_constr.datalen > 0)
11308                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11309         else
11310                 _res_constr.data = NULL;
11311         uint32_t* _res_vals = _res->elems;
11312         for (size_t q = 0; q < _res_constr.datalen; q++) {
11313                 uint32_t _res_conv_16 = _res_vals[q];
11314                 LDKChannelDetails _res_conv_16_conv;
11315                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11316                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11317                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11318                 _res_constr.data[q] = _res_conv_16_conv;
11319         }
11320         CVec_ChannelDetailsZ_free(_res_constr);
11321 }
11322
11323 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11324         LDKRoute o_conv;
11325         o_conv.inner = (void*)(o & (~1));
11326         o_conv.is_owned = (o & 1) || (o == 0);
11327         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11328         o_conv = Route_clone(&o_conv);
11329         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11330         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11331         return (uint64_t)ret_conv;
11332 }
11333
11334 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11335         LDKLightningError e_conv;
11336         e_conv.inner = (void*)(e & (~1));
11337         e_conv.is_owned = (e & 1) || (e == 0);
11338         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11339         e_conv = LightningError_clone(&e_conv);
11340         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11341         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11342         return (uint64_t)ret_conv;
11343 }
11344
11345 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11346         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11347         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11348         return ret_val;
11349 }
11350
11351 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11352         if ((_res & 1) != 0) return;
11353         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11354         CHECK_ACCESS(_res_ptr);
11355         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11356         FREE((void*)_res);
11357         CResult_RouteLightningErrorZ_free(_res_conv);
11358 }
11359
11360 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11361         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11362         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11363         return (uint64_t)ret_conv;
11364 }
11365 int64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11366         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11367         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11368         return ret_val;
11369 }
11370
11371 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
11372         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11373         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11374         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11375         return (uint64_t)ret_conv;
11376 }
11377
11378 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
11379         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11380         *ret_conv = CResult_NoneLightningErrorZ_ok();
11381         return (uint64_t)ret_conv;
11382 }
11383
11384 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
11385         LDKLightningError e_conv;
11386         e_conv.inner = (void*)(e & (~1));
11387         e_conv.is_owned = (e & 1) || (e == 0);
11388         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11389         e_conv = LightningError_clone(&e_conv);
11390         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11391         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11392         return (uint64_t)ret_conv;
11393 }
11394
11395 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
11396         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
11397         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
11398         return ret_val;
11399 }
11400
11401 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
11402         if ((_res & 1) != 0) return;
11403         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11404         CHECK_ACCESS(_res_ptr);
11405         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
11406         FREE((void*)_res);
11407         CResult_NoneLightningErrorZ_free(_res_conv);
11408 }
11409
11410 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
11411         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11412         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
11413         return (uint64_t)ret_conv;
11414 }
11415 int64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
11416         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
11417         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
11418         return ret_val;
11419 }
11420
11421 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
11422         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11423         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11424         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11425         return (uint64_t)ret_conv;
11426 }
11427
11428 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
11429         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11430         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
11431         return ((uint64_t)ret_conv);
11432 }
11433 int64_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
11434         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
11435         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
11436         return ret_val;
11437 }
11438
11439 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
11440         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
11441         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11442         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
11443         return ((uint64_t)ret_conv);
11444 }
11445
11446 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
11447         LDKPublicKey a_ref;
11448         CHECK(a->arr_len == 33);
11449         memcpy(a_ref.compressed_form, a->elems, 33);
11450         void* b_ptr = (void*)(((uint64_t)b) & ~1);
11451         CHECK_ACCESS(b_ptr);
11452         LDKType b_conv = *(LDKType*)(b_ptr);
11453         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11454         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
11455         return ((uint64_t)ret_conv);
11456 }
11457
11458 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
11459         if ((_res & 1) != 0) return;
11460         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11461         CHECK_ACCESS(_res_ptr);
11462         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
11463         FREE((void*)_res);
11464         C2Tuple_PublicKeyTypeZ_free(_res_conv);
11465 }
11466
11467 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
11468         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
11469         _res_constr.datalen = _res->arr_len;
11470         if (_res_constr.datalen > 0)
11471                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
11472         else
11473                 _res_constr.data = NULL;
11474         uint32_t* _res_vals = _res->elems;
11475         for (size_t z = 0; z < _res_constr.datalen; z++) {
11476                 uint32_t _res_conv_25 = _res_vals[z];
11477                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
11478                 CHECK_ACCESS(_res_conv_25_ptr);
11479                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
11480                 FREE((void*)_res_conv_25);
11481                 _res_constr.data[z] = _res_conv_25_conv;
11482         }
11483         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
11484 }
11485
11486 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
11487         LDKCVec_MessageSendEventZ _res_constr;
11488         _res_constr.datalen = _res->arr_len;
11489         if (_res_constr.datalen > 0)
11490                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11491         else
11492                 _res_constr.data = NULL;
11493         uint32_t* _res_vals = _res->elems;
11494         for (size_t s = 0; s < _res_constr.datalen; s++) {
11495                 uint32_t _res_conv_18 = _res_vals[s];
11496                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
11497                 CHECK_ACCESS(_res_conv_18_ptr);
11498                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
11499                 FREE((void*)_res_conv_18);
11500                 _res_constr.data[s] = _res_conv_18_conv;
11501         }
11502         CVec_MessageSendEventZ_free(_res_constr);
11503 }
11504
11505 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
11506         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11507         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11508         return (uint64_t)ret_conv;
11509 }
11510
11511 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
11512         LDKLightningError e_conv;
11513         e_conv.inner = (void*)(e & (~1));
11514         e_conv.is_owned = (e & 1) || (e == 0);
11515         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11516         e_conv = LightningError_clone(&e_conv);
11517         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11518         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11519         return (uint64_t)ret_conv;
11520 }
11521
11522 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
11523         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
11524         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
11525         return ret_val;
11526 }
11527
11528 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
11529         if ((_res & 1) != 0) return;
11530         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11531         CHECK_ACCESS(_res_ptr);
11532         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
11533         FREE((void*)_res);
11534         CResult_boolLightningErrorZ_free(_res_conv);
11535 }
11536
11537 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
11538         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11539         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
11540         return (uint64_t)ret_conv;
11541 }
11542 int64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
11543         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
11544         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
11545         return ret_val;
11546 }
11547
11548 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
11549         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11550         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11551         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11552         return (uint64_t)ret_conv;
11553 }
11554
11555 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
11556         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11557         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
11558         return ((uint64_t)ret_conv);
11559 }
11560 int64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
11561         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
11562         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
11563         return ret_val;
11564 }
11565
11566 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
11567         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11568         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11569         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11570         return ((uint64_t)ret_conv);
11571 }
11572
11573 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
11574         LDKChannelAnnouncement a_conv;
11575         a_conv.inner = (void*)(a & (~1));
11576         a_conv.is_owned = (a & 1) || (a == 0);
11577         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
11578         a_conv = ChannelAnnouncement_clone(&a_conv);
11579         LDKChannelUpdate b_conv;
11580         b_conv.inner = (void*)(b & (~1));
11581         b_conv.is_owned = (b & 1) || (b == 0);
11582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11583         b_conv = ChannelUpdate_clone(&b_conv);
11584         LDKChannelUpdate c_conv;
11585         c_conv.inner = (void*)(c & (~1));
11586         c_conv.is_owned = (c & 1) || (c == 0);
11587         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
11588         c_conv = ChannelUpdate_clone(&c_conv);
11589         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11590         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11591         return ((uint64_t)ret_conv);
11592 }
11593
11594 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
11595         if ((_res & 1) != 0) return;
11596         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11597         CHECK_ACCESS(_res_ptr);
11598         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
11599         FREE((void*)_res);
11600         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11601 }
11602
11603 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
11604         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11605         _res_constr.datalen = _res->arr_len;
11606         if (_res_constr.datalen > 0)
11607                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11608         else
11609                 _res_constr.data = NULL;
11610         uint32_t* _res_vals = _res->elems;
11611         for (size_t h = 0; h < _res_constr.datalen; h++) {
11612                 uint32_t _res_conv_59 = _res_vals[h];
11613                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
11614                 CHECK_ACCESS(_res_conv_59_ptr);
11615                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
11616                 FREE((void*)_res_conv_59);
11617                 _res_constr.data[h] = _res_conv_59_conv;
11618         }
11619         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11620 }
11621
11622 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
11623         LDKCVec_NodeAnnouncementZ _res_constr;
11624         _res_constr.datalen = _res->arr_len;
11625         if (_res_constr.datalen > 0)
11626                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11627         else
11628                 _res_constr.data = NULL;
11629         uint32_t* _res_vals = _res->elems;
11630         for (size_t s = 0; s < _res_constr.datalen; s++) {
11631                 uint32_t _res_conv_18 = _res_vals[s];
11632                 LDKNodeAnnouncement _res_conv_18_conv;
11633                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11634                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11635                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
11636                 _res_constr.data[s] = _res_conv_18_conv;
11637         }
11638         CVec_NodeAnnouncementZ_free(_res_constr);
11639 }
11640
11641 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
11642         LDKCVec_PublicKeyZ _res_constr;
11643         _res_constr.datalen = _res->arr_len;
11644         if (_res_constr.datalen > 0)
11645                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11646         else
11647                 _res_constr.data = NULL;
11648         int8_tArray* _res_vals = (void*) _res->elems;
11649         for (size_t m = 0; m < _res_constr.datalen; m++) {
11650                 int8_tArray _res_conv_12 = _res_vals[m];
11651                 LDKPublicKey _res_conv_12_ref;
11652                 CHECK(_res_conv_12->arr_len == 33);
11653                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33);
11654                 _res_constr.data[m] = _res_conv_12_ref;
11655         }
11656         CVec_PublicKeyZ_free(_res_constr);
11657 }
11658
11659 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
11660         LDKCVec_u8Z _res_ref;
11661         _res_ref.datalen = _res->arr_len;
11662         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
11663         memcpy(_res_ref.data, _res->elems, _res_ref.datalen);
11664         CVec_u8Z_free(_res_ref);
11665 }
11666
11667 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
11668         LDKCVec_u8Z o_ref;
11669         o_ref.datalen = o->arr_len;
11670         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11671         memcpy(o_ref.data, o->elems, o_ref.datalen);
11672         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11673         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11674         return (uint64_t)ret_conv;
11675 }
11676
11677 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
11678         LDKPeerHandleError e_conv;
11679         e_conv.inner = (void*)(e & (~1));
11680         e_conv.is_owned = (e & 1) || (e == 0);
11681         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11682         e_conv = PeerHandleError_clone(&e_conv);
11683         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11684         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11685         return (uint64_t)ret_conv;
11686 }
11687
11688 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
11689         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
11690         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
11691         return ret_val;
11692 }
11693
11694 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
11695         if ((_res & 1) != 0) return;
11696         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11697         CHECK_ACCESS(_res_ptr);
11698         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
11699         FREE((void*)_res);
11700         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11701 }
11702
11703 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
11704         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11705         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
11706         return (uint64_t)ret_conv;
11707 }
11708 int64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11709         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
11710         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
11711         return ret_val;
11712 }
11713
11714 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
11715         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11716         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11717         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11718         return (uint64_t)ret_conv;
11719 }
11720
11721 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
11722         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11723         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11724         return (uint64_t)ret_conv;
11725 }
11726
11727 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
11728         LDKPeerHandleError e_conv;
11729         e_conv.inner = (void*)(e & (~1));
11730         e_conv.is_owned = (e & 1) || (e == 0);
11731         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11732         e_conv = PeerHandleError_clone(&e_conv);
11733         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11734         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11735         return (uint64_t)ret_conv;
11736 }
11737
11738 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
11739         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
11740         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
11741         return ret_val;
11742 }
11743
11744 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
11745         if ((_res & 1) != 0) return;
11746         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11747         CHECK_ACCESS(_res_ptr);
11748         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
11749         FREE((void*)_res);
11750         CResult_NonePeerHandleErrorZ_free(_res_conv);
11751 }
11752
11753 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
11754         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11755         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
11756         return (uint64_t)ret_conv;
11757 }
11758 int64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
11759         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
11760         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
11761         return ret_val;
11762 }
11763
11764 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
11765         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11766         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11767         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11768         return (uint64_t)ret_conv;
11769 }
11770
11771 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
11772         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11773         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11774         return (uint64_t)ret_conv;
11775 }
11776
11777 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
11778         LDKPeerHandleError e_conv;
11779         e_conv.inner = (void*)(e & (~1));
11780         e_conv.is_owned = (e & 1) || (e == 0);
11781         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11782         e_conv = PeerHandleError_clone(&e_conv);
11783         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11784         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11785         return (uint64_t)ret_conv;
11786 }
11787
11788 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
11789         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
11790         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
11791         return ret_val;
11792 }
11793
11794 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
11795         if ((_res & 1) != 0) return;
11796         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11797         CHECK_ACCESS(_res_ptr);
11798         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
11799         FREE((void*)_res);
11800         CResult_boolPeerHandleErrorZ_free(_res_conv);
11801 }
11802
11803 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
11804         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11805         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
11806         return (uint64_t)ret_conv;
11807 }
11808 int64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11809         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
11810         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
11811         return ret_val;
11812 }
11813
11814 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
11815         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11816         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11817         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11818         return (uint64_t)ret_conv;
11819 }
11820
11821 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
11822         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11823         CHECK_ACCESS(o_ptr);
11824         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11825         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
11826         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11827         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11828         return (uint64_t)ret_conv;
11829 }
11830
11831 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
11832         LDKAccessError e_conv = LDKAccessError_from_js(e);
11833         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11834         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11835         return (uint64_t)ret_conv;
11836 }
11837
11838 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
11839         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
11840         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
11841         return ret_val;
11842 }
11843
11844 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
11845         if ((_res & 1) != 0) return;
11846         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11847         CHECK_ACCESS(_res_ptr);
11848         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11849         FREE((void*)_res);
11850         CResult_TxOutAccessErrorZ_free(_res_conv);
11851 }
11852
11853 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
11854         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11855         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
11856         return (uint64_t)ret_conv;
11857 }
11858 int64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
11859         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
11860         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
11861         return ret_val;
11862 }
11863
11864 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
11865         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11866         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11867         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11868         return (uint64_t)ret_conv;
11869 }
11870
11871 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
11872         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11873         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11874         return (uint64_t)ret_conv;
11875 }
11876
11877 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
11878         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
11879         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11880         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11881         return (uint64_t)ret_conv;
11882 }
11883
11884 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
11885         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
11886         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
11887         return ret_val;
11888 }
11889
11890 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
11891         if ((_res & 1) != 0) return;
11892         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11893         CHECK_ACCESS(_res_ptr);
11894         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
11895         FREE((void*)_res);
11896         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11897 }
11898
11899 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
11900         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11901         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
11902         return (uint64_t)ret_conv;
11903 }
11904 int64_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
11905         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
11906         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
11907         return ret_val;
11908 }
11909
11910 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
11911         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11912         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11913         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11914         return (uint64_t)ret_conv;
11915 }
11916
11917 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
11918         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11919         CHECK_ACCESS(o_ptr);
11920         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
11921         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
11922         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11923         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11924         uint64_t ret_ref = (uint64_t)ret_copy;
11925         return ret_ref;
11926 }
11927
11928 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
11929         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11930         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11931         uint64_t ret_ref = (uint64_t)ret_copy;
11932         return ret_ref;
11933 }
11934
11935 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
11936         if ((_res & 1) != 0) return;
11937         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11938         CHECK_ACCESS(_res_ptr);
11939         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
11940         FREE((void*)_res);
11941         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11942 }
11943
11944 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
11945         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11946         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
11947 uint64_t ret_ref = (uint64_t)ret_copy;
11948         return ret_ref;
11949 }
11950 int64_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
11951         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
11952         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
11953         return ret_val;
11954 }
11955
11956 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
11957         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11958         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11959         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11960         uint64_t ret_ref = (uint64_t)ret_copy;
11961         return ret_ref;
11962 }
11963
11964 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
11965         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11966         CHECK_ACCESS(o_ptr);
11967         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
11968         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
11969         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11970         *ret_copy = COption_ClosureReasonZ_some(o_conv);
11971         uint64_t ret_ref = (uint64_t)ret_copy;
11972         return ret_ref;
11973 }
11974
11975 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
11976         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11977         *ret_copy = COption_ClosureReasonZ_none();
11978         uint64_t ret_ref = (uint64_t)ret_copy;
11979         return ret_ref;
11980 }
11981
11982 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
11983         if ((_res & 1) != 0) return;
11984         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11985         CHECK_ACCESS(_res_ptr);
11986         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
11987         FREE((void*)_res);
11988         COption_ClosureReasonZ_free(_res_conv);
11989 }
11990
11991 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
11992         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11993         *ret_copy = COption_ClosureReasonZ_clone(arg);
11994 uint64_t ret_ref = (uint64_t)ret_copy;
11995         return ret_ref;
11996 }
11997 int64_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
11998         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
11999         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12000         return ret_val;
12001 }
12002
12003 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12004         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12005         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12006         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12007         uint64_t ret_ref = (uint64_t)ret_copy;
12008         return ret_ref;
12009 }
12010
12011 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12012         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12013         CHECK_ACCESS(o_ptr);
12014         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12015         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
12016         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12017         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12018         return (uint64_t)ret_conv;
12019 }
12020
12021 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12022         LDKDecodeError e_conv;
12023         e_conv.inner = (void*)(e & (~1));
12024         e_conv.is_owned = (e & 1) || (e == 0);
12025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12026         e_conv = DecodeError_clone(&e_conv);
12027         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12028         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12029         return (uint64_t)ret_conv;
12030 }
12031
12032 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12033         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12034         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12035         return ret_val;
12036 }
12037
12038 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12039         if ((_res & 1) != 0) return;
12040         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12041         CHECK_ACCESS(_res_ptr);
12042         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12043         FREE((void*)_res);
12044         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12045 }
12046
12047 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12048         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12049         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12050         return (uint64_t)ret_conv;
12051 }
12052 int64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12053         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12054         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12055         return ret_val;
12056 }
12057
12058 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12059         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12060         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12061         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12062         return (uint64_t)ret_conv;
12063 }
12064
12065 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12066         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12067         CHECK_ACCESS(o_ptr);
12068         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12069         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
12070         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12071         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12072         uint64_t ret_ref = (uint64_t)ret_copy;
12073         return ret_ref;
12074 }
12075
12076 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12077         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12078         *ret_copy = COption_NetworkUpdateZ_none();
12079         uint64_t ret_ref = (uint64_t)ret_copy;
12080         return ret_ref;
12081 }
12082
12083 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12084         if ((_res & 1) != 0) return;
12085         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12086         CHECK_ACCESS(_res_ptr);
12087         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12088         FREE((void*)_res);
12089         COption_NetworkUpdateZ_free(_res_conv);
12090 }
12091
12092 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12093         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12094         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12095 uint64_t ret_ref = (uint64_t)ret_copy;
12096         return ret_ref;
12097 }
12098 int64_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12099         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12100         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12101         return ret_val;
12102 }
12103
12104 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12105         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12106         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12107         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12108         uint64_t ret_ref = (uint64_t)ret_copy;
12109         return ret_ref;
12110 }
12111
12112 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12113         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12114         _res_constr.datalen = _res->arr_len;
12115         if (_res_constr.datalen > 0)
12116                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12117         else
12118                 _res_constr.data = NULL;
12119         uint32_t* _res_vals = _res->elems;
12120         for (size_t b = 0; b < _res_constr.datalen; b++) {
12121                 uint32_t _res_conv_27 = _res_vals[b];
12122                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
12123                 CHECK_ACCESS(_res_conv_27_ptr);
12124                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12125                 FREE((void*)_res_conv_27);
12126                 _res_constr.data[b] = _res_conv_27_conv;
12127         }
12128         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12132         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12133         CHECK_ACCESS(o_ptr);
12134         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12135         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
12136         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12137         *ret_copy = COption_EventZ_some(o_conv);
12138         uint64_t ret_ref = (uint64_t)ret_copy;
12139         return ret_ref;
12140 }
12141
12142 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12143         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12144         *ret_copy = COption_EventZ_none();
12145         uint64_t ret_ref = (uint64_t)ret_copy;
12146         return ret_ref;
12147 }
12148
12149 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12150         if ((_res & 1) != 0) return;
12151         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12152         CHECK_ACCESS(_res_ptr);
12153         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12154         FREE((void*)_res);
12155         COption_EventZ_free(_res_conv);
12156 }
12157
12158 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12159         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12160         *ret_copy = COption_EventZ_clone(arg);
12161 uint64_t ret_ref = (uint64_t)ret_copy;
12162         return ret_ref;
12163 }
12164 int64_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12165         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12166         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12167         return ret_val;
12168 }
12169
12170 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12171         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12172         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12173         *ret_copy = COption_EventZ_clone(orig_conv);
12174         uint64_t ret_ref = (uint64_t)ret_copy;
12175         return ret_ref;
12176 }
12177
12178 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12179         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12180         CHECK_ACCESS(o_ptr);
12181         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12182         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
12183         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12184         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12185         return (uint64_t)ret_conv;
12186 }
12187
12188 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12189         LDKDecodeError e_conv;
12190         e_conv.inner = (void*)(e & (~1));
12191         e_conv.is_owned = (e & 1) || (e == 0);
12192         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12193         e_conv = DecodeError_clone(&e_conv);
12194         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12195         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12196         return (uint64_t)ret_conv;
12197 }
12198
12199 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12200         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12201         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12202         return ret_val;
12203 }
12204
12205 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12206         if ((_res & 1) != 0) return;
12207         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12208         CHECK_ACCESS(_res_ptr);
12209         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12210         FREE((void*)_res);
12211         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12212 }
12213
12214 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12215         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12216         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12217         return (uint64_t)ret_conv;
12218 }
12219 int64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12220         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12221         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12222         return ret_val;
12223 }
12224
12225 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12226         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12227         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12228         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12229         return (uint64_t)ret_conv;
12230 }
12231
12232 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
12233         LDKNodeId o_conv;
12234         o_conv.inner = (void*)(o & (~1));
12235         o_conv.is_owned = (o & 1) || (o == 0);
12236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12237         o_conv = NodeId_clone(&o_conv);
12238         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12239         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
12240         return (uint64_t)ret_conv;
12241 }
12242
12243 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
12244         LDKDecodeError e_conv;
12245         e_conv.inner = (void*)(e & (~1));
12246         e_conv.is_owned = (e & 1) || (e == 0);
12247         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12248         e_conv = DecodeError_clone(&e_conv);
12249         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12250         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
12251         return (uint64_t)ret_conv;
12252 }
12253
12254 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
12255         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
12256         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
12257         return ret_val;
12258 }
12259
12260 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
12261         if ((_res & 1) != 0) return;
12262         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12263         CHECK_ACCESS(_res_ptr);
12264         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
12265         FREE((void*)_res);
12266         CResult_NodeIdDecodeErrorZ_free(_res_conv);
12267 }
12268
12269 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
12270         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12271         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
12272         return (uint64_t)ret_conv;
12273 }
12274 int64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
12275         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
12276         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
12277         return ret_val;
12278 }
12279
12280 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
12281         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
12282         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12283         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
12284         return (uint64_t)ret_conv;
12285 }
12286
12287 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
12288         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12289         CHECK_ACCESS(o_ptr);
12290         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
12291         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
12292         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12293         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
12294         return (uint64_t)ret_conv;
12295 }
12296
12297 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
12298         LDKDecodeError e_conv;
12299         e_conv.inner = (void*)(e & (~1));
12300         e_conv.is_owned = (e & 1) || (e == 0);
12301         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12302         e_conv = DecodeError_clone(&e_conv);
12303         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12304         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
12305         return (uint64_t)ret_conv;
12306 }
12307
12308 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
12309         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
12310         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
12311         return ret_val;
12312 }
12313
12314 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
12315         if ((_res & 1) != 0) return;
12316         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12317         CHECK_ACCESS(_res_ptr);
12318         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
12319         FREE((void*)_res);
12320         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
12321 }
12322
12323 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
12324         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12325         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
12326         return (uint64_t)ret_conv;
12327 }
12328 int64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
12329         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
12330         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
12331         return ret_val;
12332 }
12333
12334 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
12335         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
12336         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12337         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
12338         return (uint64_t)ret_conv;
12339 }
12340
12341 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
12342         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12343         CHECK_ACCESS(o_ptr);
12344         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
12345         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12346         *ret_copy = COption_AccessZ_some(o_conv);
12347         uint64_t ret_ref = (uint64_t)ret_copy;
12348         return ret_ref;
12349 }
12350
12351 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
12352         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12353         *ret_copy = COption_AccessZ_none();
12354         uint64_t ret_ref = (uint64_t)ret_copy;
12355         return ret_ref;
12356 }
12357
12358 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
12359         if ((_res & 1) != 0) return;
12360         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12361         CHECK_ACCESS(_res_ptr);
12362         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
12363         FREE((void*)_res);
12364         COption_AccessZ_free(_res_conv);
12365 }
12366
12367 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
12368         LDKDirectionalChannelInfo o_conv;
12369         o_conv.inner = (void*)(o & (~1));
12370         o_conv.is_owned = (o & 1) || (o == 0);
12371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12372         o_conv = DirectionalChannelInfo_clone(&o_conv);
12373         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12374         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12375         return (uint64_t)ret_conv;
12376 }
12377
12378 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
12379         LDKDecodeError e_conv;
12380         e_conv.inner = (void*)(e & (~1));
12381         e_conv.is_owned = (e & 1) || (e == 0);
12382         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12383         e_conv = DecodeError_clone(&e_conv);
12384         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12385         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12386         return (uint64_t)ret_conv;
12387 }
12388
12389 jboolean  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12390         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
12391         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
12392         return ret_val;
12393 }
12394
12395 void  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_free"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
12396         if ((_res & 1) != 0) return;
12397         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12398         CHECK_ACCESS(_res_ptr);
12399         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
12400         FREE((void*)_res);
12401         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12402 }
12403
12404 static inline uintptr_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12405         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12406         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
12407         return (uint64_t)ret_conv;
12408 }
12409 int64_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12410         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
12411         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12412         return ret_val;
12413 }
12414
12415 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12416         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12417         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12418         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12419         return (uint64_t)ret_conv;
12420 }
12421
12422 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
12423         LDKChannelInfo o_conv;
12424         o_conv.inner = (void*)(o & (~1));
12425         o_conv.is_owned = (o & 1) || (o == 0);
12426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12427         o_conv = ChannelInfo_clone(&o_conv);
12428         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12429         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12430         return (uint64_t)ret_conv;
12431 }
12432
12433 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
12434         LDKDecodeError e_conv;
12435         e_conv.inner = (void*)(e & (~1));
12436         e_conv.is_owned = (e & 1) || (e == 0);
12437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12438         e_conv = DecodeError_clone(&e_conv);
12439         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12440         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12441         return (uint64_t)ret_conv;
12442 }
12443
12444 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12445         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
12446         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
12447         return ret_val;
12448 }
12449
12450 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
12451         if ((_res & 1) != 0) return;
12452         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12453         CHECK_ACCESS(_res_ptr);
12454         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
12455         FREE((void*)_res);
12456         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12457 }
12458
12459 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12460         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12461         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
12462         return (uint64_t)ret_conv;
12463 }
12464 int64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12465         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
12466         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12467         return ret_val;
12468 }
12469
12470 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12471         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12472         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12473         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12474         return (uint64_t)ret_conv;
12475 }
12476
12477 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
12478         LDKRoutingFees o_conv;
12479         o_conv.inner = (void*)(o & (~1));
12480         o_conv.is_owned = (o & 1) || (o == 0);
12481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12482         o_conv = RoutingFees_clone(&o_conv);
12483         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12484         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12485         return (uint64_t)ret_conv;
12486 }
12487
12488 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
12489         LDKDecodeError e_conv;
12490         e_conv.inner = (void*)(e & (~1));
12491         e_conv.is_owned = (e & 1) || (e == 0);
12492         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12493         e_conv = DecodeError_clone(&e_conv);
12494         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12495         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12496         return (uint64_t)ret_conv;
12497 }
12498
12499 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
12500         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
12501         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
12502         return ret_val;
12503 }
12504
12505 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
12506         if ((_res & 1) != 0) return;
12507         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12508         CHECK_ACCESS(_res_ptr);
12509         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
12510         FREE((void*)_res);
12511         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12512 }
12513
12514 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
12515         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12516         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
12517         return (uint64_t)ret_conv;
12518 }
12519 int64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
12520         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
12521         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
12522         return ret_val;
12523 }
12524
12525 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
12526         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12527         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12528         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12529         return (uint64_t)ret_conv;
12530 }
12531
12532 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
12533         LDKCVec_NetAddressZ _res_constr;
12534         _res_constr.datalen = _res->arr_len;
12535         if (_res_constr.datalen > 0)
12536                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12537         else
12538                 _res_constr.data = NULL;
12539         uint32_t* _res_vals = _res->elems;
12540         for (size_t m = 0; m < _res_constr.datalen; m++) {
12541                 uint32_t _res_conv_12 = _res_vals[m];
12542                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
12543                 CHECK_ACCESS(_res_conv_12_ptr);
12544                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
12545                 FREE((void*)_res_conv_12);
12546                 _res_constr.data[m] = _res_conv_12_conv;
12547         }
12548         CVec_NetAddressZ_free(_res_constr);
12549 }
12550
12551 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
12552         LDKNodeAnnouncementInfo o_conv;
12553         o_conv.inner = (void*)(o & (~1));
12554         o_conv.is_owned = (o & 1) || (o == 0);
12555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12556         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12557         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12558         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12559         return (uint64_t)ret_conv;
12560 }
12561
12562 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
12563         LDKDecodeError e_conv;
12564         e_conv.inner = (void*)(e & (~1));
12565         e_conv.is_owned = (e & 1) || (e == 0);
12566         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12567         e_conv = DecodeError_clone(&e_conv);
12568         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12569         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12570         return (uint64_t)ret_conv;
12571 }
12572
12573 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
12574         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
12575         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
12576         return ret_val;
12577 }
12578
12579 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
12580         if ((_res & 1) != 0) return;
12581         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12582         CHECK_ACCESS(_res_ptr);
12583         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
12584         FREE((void*)_res);
12585         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12586 }
12587
12588 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
12589         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12590         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
12591         return (uint64_t)ret_conv;
12592 }
12593 int64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12594         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
12595         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
12596         return ret_val;
12597 }
12598
12599 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
12600         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12601         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12602         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12603         return (uint64_t)ret_conv;
12604 }
12605
12606 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12607         LDKCVec_u64Z _res_constr;
12608         _res_constr.datalen = _res->arr_len;
12609         if (_res_constr.datalen > 0)
12610                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12611         else
12612                 _res_constr.data = NULL;
12613         int64_t* _res_vals = _res->elems;
12614         for (size_t i = 0; i < _res_constr.datalen; i++) {
12615                 int64_t _res_conv_8 = _res_vals[i];
12616                 _res_constr.data[i] = _res_conv_8;
12617         }
12618         CVec_u64Z_free(_res_constr);
12619 }
12620
12621 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
12622         LDKNodeInfo o_conv;
12623         o_conv.inner = (void*)(o & (~1));
12624         o_conv.is_owned = (o & 1) || (o == 0);
12625         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12626         o_conv = NodeInfo_clone(&o_conv);
12627         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12628         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12629         return (uint64_t)ret_conv;
12630 }
12631
12632 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
12633         LDKDecodeError e_conv;
12634         e_conv.inner = (void*)(e & (~1));
12635         e_conv.is_owned = (e & 1) || (e == 0);
12636         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12637         e_conv = DecodeError_clone(&e_conv);
12638         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12639         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12640         return (uint64_t)ret_conv;
12641 }
12642
12643 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
12644         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
12645         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
12646         return ret_val;
12647 }
12648
12649 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
12650         if ((_res & 1) != 0) return;
12651         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12652         CHECK_ACCESS(_res_ptr);
12653         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
12654         FREE((void*)_res);
12655         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12656 }
12657
12658 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
12659         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12660         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
12661         return (uint64_t)ret_conv;
12662 }
12663 int64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12664         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
12665         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
12666         return ret_val;
12667 }
12668
12669 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
12670         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12671         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12672         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12673         return (uint64_t)ret_conv;
12674 }
12675
12676 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
12677         LDKNetworkGraph o_conv;
12678         o_conv.inner = (void*)(o & (~1));
12679         o_conv.is_owned = (o & 1) || (o == 0);
12680         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12681         o_conv = NetworkGraph_clone(&o_conv);
12682         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12683         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12684         return (uint64_t)ret_conv;
12685 }
12686
12687 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
12688         LDKDecodeError e_conv;
12689         e_conv.inner = (void*)(e & (~1));
12690         e_conv.is_owned = (e & 1) || (e == 0);
12691         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12692         e_conv = DecodeError_clone(&e_conv);
12693         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12694         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12695         return (uint64_t)ret_conv;
12696 }
12697
12698 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
12699         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
12700         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
12701         return ret_val;
12702 }
12703
12704 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
12705         if ((_res & 1) != 0) return;
12706         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12707         CHECK_ACCESS(_res_ptr);
12708         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
12709         FREE((void*)_res);
12710         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12711 }
12712
12713 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
12714         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12715         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
12716         return (uint64_t)ret_conv;
12717 }
12718 int64_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
12719         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
12720         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
12721         return ret_val;
12722 }
12723
12724 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
12725         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12726         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12727         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12728         return (uint64_t)ret_conv;
12729 }
12730
12731 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
12732         LDKCVec_NetAddressZ o_constr;
12733         o_constr.datalen = o->arr_len;
12734         if (o_constr.datalen > 0)
12735                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12736         else
12737                 o_constr.data = NULL;
12738         uint32_t* o_vals = o->elems;
12739         for (size_t m = 0; m < o_constr.datalen; m++) {
12740                 uint32_t o_conv_12 = o_vals[m];
12741                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
12742                 CHECK_ACCESS(o_conv_12_ptr);
12743                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
12744                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
12745                 o_constr.data[m] = o_conv_12_conv;
12746         }
12747         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12748         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
12749         uint64_t ret_ref = (uint64_t)ret_copy;
12750         return ret_ref;
12751 }
12752
12753 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
12754         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12755         *ret_copy = COption_CVec_NetAddressZZ_none();
12756         uint64_t ret_ref = (uint64_t)ret_copy;
12757         return ret_ref;
12758 }
12759
12760 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
12761         if ((_res & 1) != 0) return;
12762         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12763         CHECK_ACCESS(_res_ptr);
12764         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
12765         FREE((void*)_res);
12766         COption_CVec_NetAddressZZ_free(_res_conv);
12767 }
12768
12769 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
12770         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12771         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
12772 uint64_t ret_ref = (uint64_t)ret_copy;
12773         return ret_ref;
12774 }
12775 int64_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
12776         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
12777         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
12778         return ret_val;
12779 }
12780
12781 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
12782         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
12783         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12784         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
12785         uint64_t ret_ref = (uint64_t)ret_copy;
12786         return ret_ref;
12787 }
12788
12789 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12790         LDKScoringParameters o_conv;
12791         o_conv.inner = (void*)(o & (~1));
12792         o_conv.is_owned = (o & 1) || (o == 0);
12793         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12794         // Warning: we need a move here but no clone is available for LDKScoringParameters
12795         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12796         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12797         return (uint64_t)ret_conv;
12798 }
12799
12800 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12801         LDKDecodeError e_conv;
12802         e_conv.inner = (void*)(e & (~1));
12803         e_conv.is_owned = (e & 1) || (e == 0);
12804         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12805         e_conv = DecodeError_clone(&e_conv);
12806         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12807         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12808         return (uint64_t)ret_conv;
12809 }
12810
12811 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12812         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12813         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12814         return ret_val;
12815 }
12816
12817 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12818         if ((_res & 1) != 0) return;
12819         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12820         CHECK_ACCESS(_res_ptr);
12821         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12822         FREE((void*)_res);
12823         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12824 }
12825
12826 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12827         LDKInitFeatures o_conv;
12828         o_conv.inner = (void*)(o & (~1));
12829         o_conv.is_owned = (o & 1) || (o == 0);
12830         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12831         o_conv = InitFeatures_clone(&o_conv);
12832         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12833         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12834         return (uint64_t)ret_conv;
12835 }
12836
12837 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12838         LDKDecodeError e_conv;
12839         e_conv.inner = (void*)(e & (~1));
12840         e_conv.is_owned = (e & 1) || (e == 0);
12841         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12842         e_conv = DecodeError_clone(&e_conv);
12843         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12844         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12845         return (uint64_t)ret_conv;
12846 }
12847
12848 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12849         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12850         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12851         return ret_val;
12852 }
12853
12854 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12855         if ((_res & 1) != 0) return;
12856         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12857         CHECK_ACCESS(_res_ptr);
12858         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12859         FREE((void*)_res);
12860         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12861 }
12862
12863 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12864         LDKChannelFeatures o_conv;
12865         o_conv.inner = (void*)(o & (~1));
12866         o_conv.is_owned = (o & 1) || (o == 0);
12867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12868         o_conv = ChannelFeatures_clone(&o_conv);
12869         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12870         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12871         return (uint64_t)ret_conv;
12872 }
12873
12874 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12875         LDKDecodeError e_conv;
12876         e_conv.inner = (void*)(e & (~1));
12877         e_conv.is_owned = (e & 1) || (e == 0);
12878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12879         e_conv = DecodeError_clone(&e_conv);
12880         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12881         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12882         return (uint64_t)ret_conv;
12883 }
12884
12885 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12886         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12887         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12888         return ret_val;
12889 }
12890
12891 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12892         if ((_res & 1) != 0) return;
12893         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12894         CHECK_ACCESS(_res_ptr);
12895         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12896         FREE((void*)_res);
12897         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12898 }
12899
12900 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12901         LDKNodeFeatures o_conv;
12902         o_conv.inner = (void*)(o & (~1));
12903         o_conv.is_owned = (o & 1) || (o == 0);
12904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12905         o_conv = NodeFeatures_clone(&o_conv);
12906         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12907         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12908         return (uint64_t)ret_conv;
12909 }
12910
12911 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12912         LDKDecodeError e_conv;
12913         e_conv.inner = (void*)(e & (~1));
12914         e_conv.is_owned = (e & 1) || (e == 0);
12915         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12916         e_conv = DecodeError_clone(&e_conv);
12917         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12918         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12919         return (uint64_t)ret_conv;
12920 }
12921
12922 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12923         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12924         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12925         return ret_val;
12926 }
12927
12928 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12929         if ((_res & 1) != 0) return;
12930         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12931         CHECK_ACCESS(_res_ptr);
12932         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12933         FREE((void*)_res);
12934         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12935 }
12936
12937 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12938         LDKInvoiceFeatures o_conv;
12939         o_conv.inner = (void*)(o & (~1));
12940         o_conv.is_owned = (o & 1) || (o == 0);
12941         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12942         o_conv = InvoiceFeatures_clone(&o_conv);
12943         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12944         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12945         return (uint64_t)ret_conv;
12946 }
12947
12948 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12949         LDKDecodeError e_conv;
12950         e_conv.inner = (void*)(e & (~1));
12951         e_conv.is_owned = (e & 1) || (e == 0);
12952         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12953         e_conv = DecodeError_clone(&e_conv);
12954         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12955         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12956         return (uint64_t)ret_conv;
12957 }
12958
12959 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12960         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12961         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12962         return ret_val;
12963 }
12964
12965 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12966         if ((_res & 1) != 0) return;
12967         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12968         CHECK_ACCESS(_res_ptr);
12969         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12970         FREE((void*)_res);
12971         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12972 }
12973
12974 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12975         LDKChannelTypeFeatures o_conv;
12976         o_conv.inner = (void*)(o & (~1));
12977         o_conv.is_owned = (o & 1) || (o == 0);
12978         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12979         o_conv = ChannelTypeFeatures_clone(&o_conv);
12980         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12981         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12982         return (uint64_t)ret_conv;
12983 }
12984
12985 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12986         LDKDecodeError e_conv;
12987         e_conv.inner = (void*)(e & (~1));
12988         e_conv.is_owned = (e & 1) || (e == 0);
12989         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12990         e_conv = DecodeError_clone(&e_conv);
12991         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12992         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
12993         return (uint64_t)ret_conv;
12994 }
12995
12996 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12997         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
12998         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
12999         return ret_val;
13000 }
13001
13002 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13003         if ((_res & 1) != 0) return;
13004         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13005         CHECK_ACCESS(_res_ptr);
13006         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13007         FREE((void*)_res);
13008         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13009 }
13010
13011 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
13012         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13013         CHECK_ACCESS(o_ptr);
13014         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
13015         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
13016         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13017         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
13018         return (uint64_t)ret_conv;
13019 }
13020
13021 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
13022         LDKDecodeError e_conv;
13023         e_conv.inner = (void*)(e & (~1));
13024         e_conv.is_owned = (e & 1) || (e == 0);
13025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13026         e_conv = DecodeError_clone(&e_conv);
13027         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13028         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
13029         return (uint64_t)ret_conv;
13030 }
13031
13032 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
13033         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
13034         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
13035         return ret_val;
13036 }
13037
13038 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
13039         if ((_res & 1) != 0) return;
13040         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13041         CHECK_ACCESS(_res_ptr);
13042         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
13043         FREE((void*)_res);
13044         CResult_NetAddressDecodeErrorZ_free(_res_conv);
13045 }
13046
13047 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
13048         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13049         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
13050         return (uint64_t)ret_conv;
13051 }
13052 int64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
13053         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
13054         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
13055         return ret_val;
13056 }
13057
13058 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
13059         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
13060         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13061         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
13062         return (uint64_t)ret_conv;
13063 }
13064
13065 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
13066         LDKCVec_UpdateAddHTLCZ _res_constr;
13067         _res_constr.datalen = _res->arr_len;
13068         if (_res_constr.datalen > 0)
13069                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
13070         else
13071                 _res_constr.data = NULL;
13072         uint32_t* _res_vals = _res->elems;
13073         for (size_t p = 0; p < _res_constr.datalen; p++) {
13074                 uint32_t _res_conv_15 = _res_vals[p];
13075                 LDKUpdateAddHTLC _res_conv_15_conv;
13076                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
13077                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
13078                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
13079                 _res_constr.data[p] = _res_conv_15_conv;
13080         }
13081         CVec_UpdateAddHTLCZ_free(_res_constr);
13082 }
13083
13084 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
13085         LDKCVec_UpdateFulfillHTLCZ _res_constr;
13086         _res_constr.datalen = _res->arr_len;
13087         if (_res_constr.datalen > 0)
13088                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
13089         else
13090                 _res_constr.data = NULL;
13091         uint32_t* _res_vals = _res->elems;
13092         for (size_t t = 0; t < _res_constr.datalen; t++) {
13093                 uint32_t _res_conv_19 = _res_vals[t];
13094                 LDKUpdateFulfillHTLC _res_conv_19_conv;
13095                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
13096                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
13097                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
13098                 _res_constr.data[t] = _res_conv_19_conv;
13099         }
13100         CVec_UpdateFulfillHTLCZ_free(_res_constr);
13101 }
13102
13103 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
13104         LDKCVec_UpdateFailHTLCZ _res_constr;
13105         _res_constr.datalen = _res->arr_len;
13106         if (_res_constr.datalen > 0)
13107                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
13108         else
13109                 _res_constr.data = NULL;
13110         uint32_t* _res_vals = _res->elems;
13111         for (size_t q = 0; q < _res_constr.datalen; q++) {
13112                 uint32_t _res_conv_16 = _res_vals[q];
13113                 LDKUpdateFailHTLC _res_conv_16_conv;
13114                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13115                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13116                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
13117                 _res_constr.data[q] = _res_conv_16_conv;
13118         }
13119         CVec_UpdateFailHTLCZ_free(_res_constr);
13120 }
13121
13122 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
13123         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
13124         _res_constr.datalen = _res->arr_len;
13125         if (_res_constr.datalen > 0)
13126                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
13127         else
13128                 _res_constr.data = NULL;
13129         uint32_t* _res_vals = _res->elems;
13130         for (size_t z = 0; z < _res_constr.datalen; z++) {
13131                 uint32_t _res_conv_25 = _res_vals[z];
13132                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
13133                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
13134                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
13135                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
13136                 _res_constr.data[z] = _res_conv_25_conv;
13137         }
13138         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
13139 }
13140
13141 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
13142         LDKAcceptChannel o_conv;
13143         o_conv.inner = (void*)(o & (~1));
13144         o_conv.is_owned = (o & 1) || (o == 0);
13145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13146         o_conv = AcceptChannel_clone(&o_conv);
13147         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13148         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
13149         return (uint64_t)ret_conv;
13150 }
13151
13152 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
13153         LDKDecodeError e_conv;
13154         e_conv.inner = (void*)(e & (~1));
13155         e_conv.is_owned = (e & 1) || (e == 0);
13156         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13157         e_conv = DecodeError_clone(&e_conv);
13158         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13159         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
13160         return (uint64_t)ret_conv;
13161 }
13162
13163 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
13164         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
13165         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
13166         return ret_val;
13167 }
13168
13169 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
13170         if ((_res & 1) != 0) return;
13171         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13172         CHECK_ACCESS(_res_ptr);
13173         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
13174         FREE((void*)_res);
13175         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
13176 }
13177
13178 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
13179         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13180         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
13181         return (uint64_t)ret_conv;
13182 }
13183 int64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13184         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
13185         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
13186         return ret_val;
13187 }
13188
13189 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
13190         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
13191         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13192         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
13193         return (uint64_t)ret_conv;
13194 }
13195
13196 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
13197         LDKAnnouncementSignatures o_conv;
13198         o_conv.inner = (void*)(o & (~1));
13199         o_conv.is_owned = (o & 1) || (o == 0);
13200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13201         o_conv = AnnouncementSignatures_clone(&o_conv);
13202         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13203         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
13204         return (uint64_t)ret_conv;
13205 }
13206
13207 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
13208         LDKDecodeError e_conv;
13209         e_conv.inner = (void*)(e & (~1));
13210         e_conv.is_owned = (e & 1) || (e == 0);
13211         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13212         e_conv = DecodeError_clone(&e_conv);
13213         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13214         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
13215         return (uint64_t)ret_conv;
13216 }
13217
13218 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
13219         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
13220         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
13221         return ret_val;
13222 }
13223
13224 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
13225         if ((_res & 1) != 0) return;
13226         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13227         CHECK_ACCESS(_res_ptr);
13228         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
13229         FREE((void*)_res);
13230         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
13231 }
13232
13233 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
13234         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13235         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
13236         return (uint64_t)ret_conv;
13237 }
13238 int64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13239         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
13240         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
13241         return ret_val;
13242 }
13243
13244 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
13245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
13246         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13247         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
13248         return (uint64_t)ret_conv;
13249 }
13250
13251 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
13252         LDKChannelReestablish o_conv;
13253         o_conv.inner = (void*)(o & (~1));
13254         o_conv.is_owned = (o & 1) || (o == 0);
13255         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13256         o_conv = ChannelReestablish_clone(&o_conv);
13257         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13258         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
13259         return (uint64_t)ret_conv;
13260 }
13261
13262 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
13263         LDKDecodeError e_conv;
13264         e_conv.inner = (void*)(e & (~1));
13265         e_conv.is_owned = (e & 1) || (e == 0);
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13267         e_conv = DecodeError_clone(&e_conv);
13268         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13269         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
13270         return (uint64_t)ret_conv;
13271 }
13272
13273 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
13274         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
13275         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
13276         return ret_val;
13277 }
13278
13279 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
13280         if ((_res & 1) != 0) return;
13281         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13282         CHECK_ACCESS(_res_ptr);
13283         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
13284         FREE((void*)_res);
13285         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
13286 }
13287
13288 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
13289         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13290         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
13291         return (uint64_t)ret_conv;
13292 }
13293 int64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
13294         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
13295         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
13296         return ret_val;
13297 }
13298
13299 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
13300         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
13301         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13302         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
13303         return (uint64_t)ret_conv;
13304 }
13305
13306 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
13307         LDKClosingSigned o_conv;
13308         o_conv.inner = (void*)(o & (~1));
13309         o_conv.is_owned = (o & 1) || (o == 0);
13310         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13311         o_conv = ClosingSigned_clone(&o_conv);
13312         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13313         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
13314         return (uint64_t)ret_conv;
13315 }
13316
13317 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
13318         LDKDecodeError e_conv;
13319         e_conv.inner = (void*)(e & (~1));
13320         e_conv.is_owned = (e & 1) || (e == 0);
13321         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13322         e_conv = DecodeError_clone(&e_conv);
13323         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13324         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
13325         return (uint64_t)ret_conv;
13326 }
13327
13328 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
13329         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
13330         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
13331         return ret_val;
13332 }
13333
13334 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
13335         if ((_res & 1) != 0) return;
13336         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13337         CHECK_ACCESS(_res_ptr);
13338         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
13339         FREE((void*)_res);
13340         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
13341 }
13342
13343 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
13344         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13345         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
13346         return (uint64_t)ret_conv;
13347 }
13348 int64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13349         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
13350         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
13351         return ret_val;
13352 }
13353
13354 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
13355         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
13356         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13357         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
13358         return (uint64_t)ret_conv;
13359 }
13360
13361 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
13362         LDKClosingSignedFeeRange o_conv;
13363         o_conv.inner = (void*)(o & (~1));
13364         o_conv.is_owned = (o & 1) || (o == 0);
13365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13366         o_conv = ClosingSignedFeeRange_clone(&o_conv);
13367         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13368         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
13369         return (uint64_t)ret_conv;
13370 }
13371
13372 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
13373         LDKDecodeError e_conv;
13374         e_conv.inner = (void*)(e & (~1));
13375         e_conv.is_owned = (e & 1) || (e == 0);
13376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13377         e_conv = DecodeError_clone(&e_conv);
13378         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13379         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
13380         return (uint64_t)ret_conv;
13381 }
13382
13383 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
13384         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
13385         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
13386         return ret_val;
13387 }
13388
13389 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
13390         if ((_res & 1) != 0) return;
13391         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13392         CHECK_ACCESS(_res_ptr);
13393         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
13394         FREE((void*)_res);
13395         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
13396 }
13397
13398 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
13399         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13400         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
13401         return (uint64_t)ret_conv;
13402 }
13403 int64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
13404         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
13405         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
13406         return ret_val;
13407 }
13408
13409 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
13410         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
13411         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13412         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
13413         return (uint64_t)ret_conv;
13414 }
13415
13416 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
13417         LDKCommitmentSigned o_conv;
13418         o_conv.inner = (void*)(o & (~1));
13419         o_conv.is_owned = (o & 1) || (o == 0);
13420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13421         o_conv = CommitmentSigned_clone(&o_conv);
13422         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13423         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
13424         return (uint64_t)ret_conv;
13425 }
13426
13427 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
13428         LDKDecodeError e_conv;
13429         e_conv.inner = (void*)(e & (~1));
13430         e_conv.is_owned = (e & 1) || (e == 0);
13431         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13432         e_conv = DecodeError_clone(&e_conv);
13433         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13434         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
13435         return (uint64_t)ret_conv;
13436 }
13437
13438 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
13439         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
13440         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
13441         return ret_val;
13442 }
13443
13444 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
13445         if ((_res & 1) != 0) return;
13446         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13447         CHECK_ACCESS(_res_ptr);
13448         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
13449         FREE((void*)_res);
13450         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
13451 }
13452
13453 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
13454         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13455         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
13456         return (uint64_t)ret_conv;
13457 }
13458 int64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13459         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
13460         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
13461         return ret_val;
13462 }
13463
13464 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
13465         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
13466         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13467         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
13468         return (uint64_t)ret_conv;
13469 }
13470
13471 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
13472         LDKFundingCreated o_conv;
13473         o_conv.inner = (void*)(o & (~1));
13474         o_conv.is_owned = (o & 1) || (o == 0);
13475         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13476         o_conv = FundingCreated_clone(&o_conv);
13477         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13478         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
13479         return (uint64_t)ret_conv;
13480 }
13481
13482 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
13483         LDKDecodeError e_conv;
13484         e_conv.inner = (void*)(e & (~1));
13485         e_conv.is_owned = (e & 1) || (e == 0);
13486         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13487         e_conv = DecodeError_clone(&e_conv);
13488         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13489         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
13490         return (uint64_t)ret_conv;
13491 }
13492
13493 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
13494         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
13495         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
13496         return ret_val;
13497 }
13498
13499 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
13500         if ((_res & 1) != 0) return;
13501         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13502         CHECK_ACCESS(_res_ptr);
13503         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
13504         FREE((void*)_res);
13505         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
13506 }
13507
13508 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
13509         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13510         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
13511         return (uint64_t)ret_conv;
13512 }
13513 int64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
13514         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
13515         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
13516         return ret_val;
13517 }
13518
13519 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
13520         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
13521         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13522         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
13523         return (uint64_t)ret_conv;
13524 }
13525
13526 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
13527         LDKFundingSigned o_conv;
13528         o_conv.inner = (void*)(o & (~1));
13529         o_conv.is_owned = (o & 1) || (o == 0);
13530         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13531         o_conv = FundingSigned_clone(&o_conv);
13532         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13533         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
13534         return (uint64_t)ret_conv;
13535 }
13536
13537 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
13538         LDKDecodeError e_conv;
13539         e_conv.inner = (void*)(e & (~1));
13540         e_conv.is_owned = (e & 1) || (e == 0);
13541         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13542         e_conv = DecodeError_clone(&e_conv);
13543         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13544         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
13545         return (uint64_t)ret_conv;
13546 }
13547
13548 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
13549         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
13550         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
13551         return ret_val;
13552 }
13553
13554 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
13555         if ((_res & 1) != 0) return;
13556         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13557         CHECK_ACCESS(_res_ptr);
13558         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
13559         FREE((void*)_res);
13560         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
13561 }
13562
13563 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
13564         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13565         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
13566         return (uint64_t)ret_conv;
13567 }
13568 int64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13569         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
13570         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
13571         return ret_val;
13572 }
13573
13574 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
13575         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
13576         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13577         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
13578         return (uint64_t)ret_conv;
13579 }
13580
13581 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
13582         LDKFundingLocked o_conv;
13583         o_conv.inner = (void*)(o & (~1));
13584         o_conv.is_owned = (o & 1) || (o == 0);
13585         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13586         o_conv = FundingLocked_clone(&o_conv);
13587         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13588         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
13589         return (uint64_t)ret_conv;
13590 }
13591
13592 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
13593         LDKDecodeError e_conv;
13594         e_conv.inner = (void*)(e & (~1));
13595         e_conv.is_owned = (e & 1) || (e == 0);
13596         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13597         e_conv = DecodeError_clone(&e_conv);
13598         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13599         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
13600         return (uint64_t)ret_conv;
13601 }
13602
13603 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
13604         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
13605         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
13606         return ret_val;
13607 }
13608
13609 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
13610         if ((_res & 1) != 0) return;
13611         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13612         CHECK_ACCESS(_res_ptr);
13613         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
13614         FREE((void*)_res);
13615         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
13616 }
13617
13618 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
13619         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13620         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
13621         return (uint64_t)ret_conv;
13622 }
13623 int64_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
13624         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
13625         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
13626         return ret_val;
13627 }
13628
13629 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
13630         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
13631         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13632         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
13633         return (uint64_t)ret_conv;
13634 }
13635
13636 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
13637         LDKInit o_conv;
13638         o_conv.inner = (void*)(o & (~1));
13639         o_conv.is_owned = (o & 1) || (o == 0);
13640         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13641         o_conv = Init_clone(&o_conv);
13642         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13643         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
13644         return (uint64_t)ret_conv;
13645 }
13646
13647 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
13648         LDKDecodeError e_conv;
13649         e_conv.inner = (void*)(e & (~1));
13650         e_conv.is_owned = (e & 1) || (e == 0);
13651         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13652         e_conv = DecodeError_clone(&e_conv);
13653         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13654         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
13655         return (uint64_t)ret_conv;
13656 }
13657
13658 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
13659         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
13660         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
13661         return ret_val;
13662 }
13663
13664 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
13665         if ((_res & 1) != 0) return;
13666         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13667         CHECK_ACCESS(_res_ptr);
13668         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
13669         FREE((void*)_res);
13670         CResult_InitDecodeErrorZ_free(_res_conv);
13671 }
13672
13673 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
13674         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13675         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
13676         return (uint64_t)ret_conv;
13677 }
13678 int64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
13679         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
13680         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
13681         return ret_val;
13682 }
13683
13684 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
13685         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
13686         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13687         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
13688         return (uint64_t)ret_conv;
13689 }
13690
13691 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
13692         LDKOpenChannel o_conv;
13693         o_conv.inner = (void*)(o & (~1));
13694         o_conv.is_owned = (o & 1) || (o == 0);
13695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13696         o_conv = OpenChannel_clone(&o_conv);
13697         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13698         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
13699         return (uint64_t)ret_conv;
13700 }
13701
13702 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
13703         LDKDecodeError e_conv;
13704         e_conv.inner = (void*)(e & (~1));
13705         e_conv.is_owned = (e & 1) || (e == 0);
13706         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13707         e_conv = DecodeError_clone(&e_conv);
13708         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13709         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
13710         return (uint64_t)ret_conv;
13711 }
13712
13713 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
13714         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
13715         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
13716         return ret_val;
13717 }
13718
13719 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
13720         if ((_res & 1) != 0) return;
13721         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13722         CHECK_ACCESS(_res_ptr);
13723         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
13724         FREE((void*)_res);
13725         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
13726 }
13727
13728 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
13729         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13730         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
13731         return (uint64_t)ret_conv;
13732 }
13733 int64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13734         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
13735         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
13736         return ret_val;
13737 }
13738
13739 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
13740         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
13741         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13742         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
13743         return (uint64_t)ret_conv;
13744 }
13745
13746 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
13747         LDKRevokeAndACK o_conv;
13748         o_conv.inner = (void*)(o & (~1));
13749         o_conv.is_owned = (o & 1) || (o == 0);
13750         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13751         o_conv = RevokeAndACK_clone(&o_conv);
13752         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13753         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
13754         return (uint64_t)ret_conv;
13755 }
13756
13757 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
13758         LDKDecodeError e_conv;
13759         e_conv.inner = (void*)(e & (~1));
13760         e_conv.is_owned = (e & 1) || (e == 0);
13761         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13762         e_conv = DecodeError_clone(&e_conv);
13763         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13764         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
13765         return (uint64_t)ret_conv;
13766 }
13767
13768 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
13769         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
13770         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
13771         return ret_val;
13772 }
13773
13774 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
13775         if ((_res & 1) != 0) return;
13776         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13777         CHECK_ACCESS(_res_ptr);
13778         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
13779         FREE((void*)_res);
13780         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
13781 }
13782
13783 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
13784         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13785         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
13786         return (uint64_t)ret_conv;
13787 }
13788 int64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
13789         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
13790         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
13791         return ret_val;
13792 }
13793
13794 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
13795         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
13796         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13797         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
13798         return (uint64_t)ret_conv;
13799 }
13800
13801 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
13802         LDKShutdown o_conv;
13803         o_conv.inner = (void*)(o & (~1));
13804         o_conv.is_owned = (o & 1) || (o == 0);
13805         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13806         o_conv = Shutdown_clone(&o_conv);
13807         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13808         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
13809         return (uint64_t)ret_conv;
13810 }
13811
13812 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
13813         LDKDecodeError e_conv;
13814         e_conv.inner = (void*)(e & (~1));
13815         e_conv.is_owned = (e & 1) || (e == 0);
13816         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13817         e_conv = DecodeError_clone(&e_conv);
13818         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13819         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
13820         return (uint64_t)ret_conv;
13821 }
13822
13823 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
13824         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
13825         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
13826         return ret_val;
13827 }
13828
13829 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
13830         if ((_res & 1) != 0) return;
13831         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13832         CHECK_ACCESS(_res_ptr);
13833         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
13834         FREE((void*)_res);
13835         CResult_ShutdownDecodeErrorZ_free(_res_conv);
13836 }
13837
13838 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
13839         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13840         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
13841         return (uint64_t)ret_conv;
13842 }
13843 int64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
13844         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
13845         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
13846         return ret_val;
13847 }
13848
13849 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
13850         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
13851         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13852         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
13853         return (uint64_t)ret_conv;
13854 }
13855
13856 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
13857         LDKUpdateFailHTLC o_conv;
13858         o_conv.inner = (void*)(o & (~1));
13859         o_conv.is_owned = (o & 1) || (o == 0);
13860         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13861         o_conv = UpdateFailHTLC_clone(&o_conv);
13862         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13863         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
13864         return (uint64_t)ret_conv;
13865 }
13866
13867 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
13868         LDKDecodeError e_conv;
13869         e_conv.inner = (void*)(e & (~1));
13870         e_conv.is_owned = (e & 1) || (e == 0);
13871         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13872         e_conv = DecodeError_clone(&e_conv);
13873         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13874         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
13875         return (uint64_t)ret_conv;
13876 }
13877
13878 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
13879         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
13880         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
13881         return ret_val;
13882 }
13883
13884 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
13885         if ((_res & 1) != 0) return;
13886         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13887         CHECK_ACCESS(_res_ptr);
13888         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
13889         FREE((void*)_res);
13890         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
13891 }
13892
13893 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
13894         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13895         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
13896         return (uint64_t)ret_conv;
13897 }
13898 int64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13899         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
13900         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
13901         return ret_val;
13902 }
13903
13904 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
13905         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
13906         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13907         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
13908         return (uint64_t)ret_conv;
13909 }
13910
13911 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
13912         LDKUpdateFailMalformedHTLC o_conv;
13913         o_conv.inner = (void*)(o & (~1));
13914         o_conv.is_owned = (o & 1) || (o == 0);
13915         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13916         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
13917         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13918         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
13919         return (uint64_t)ret_conv;
13920 }
13921
13922 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
13923         LDKDecodeError e_conv;
13924         e_conv.inner = (void*)(e & (~1));
13925         e_conv.is_owned = (e & 1) || (e == 0);
13926         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13927         e_conv = DecodeError_clone(&e_conv);
13928         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13929         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
13930         return (uint64_t)ret_conv;
13931 }
13932
13933 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
13934         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
13935         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
13936         return ret_val;
13937 }
13938
13939 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
13940         if ((_res & 1) != 0) return;
13941         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13942         CHECK_ACCESS(_res_ptr);
13943         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
13944         FREE((void*)_res);
13945         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
13946 }
13947
13948 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
13949         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13950         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
13951         return (uint64_t)ret_conv;
13952 }
13953 int64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13954         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
13955         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
13956         return ret_val;
13957 }
13958
13959 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
13960         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
13961         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13962         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
13963         return (uint64_t)ret_conv;
13964 }
13965
13966 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
13967         LDKUpdateFee o_conv;
13968         o_conv.inner = (void*)(o & (~1));
13969         o_conv.is_owned = (o & 1) || (o == 0);
13970         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13971         o_conv = UpdateFee_clone(&o_conv);
13972         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13973         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
13974         return (uint64_t)ret_conv;
13975 }
13976
13977 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
13978         LDKDecodeError e_conv;
13979         e_conv.inner = (void*)(e & (~1));
13980         e_conv.is_owned = (e & 1) || (e == 0);
13981         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13982         e_conv = DecodeError_clone(&e_conv);
13983         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13984         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
13985         return (uint64_t)ret_conv;
13986 }
13987
13988 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
13989         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
13990         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
13991         return ret_val;
13992 }
13993
13994 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
13995         if ((_res & 1) != 0) return;
13996         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13997         CHECK_ACCESS(_res_ptr);
13998         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
13999         FREE((void*)_res);
14000         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14001 }
14002
14003 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
14004         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14005         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
14006         return (uint64_t)ret_conv;
14007 }
14008 int64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
14009         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
14010         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
14011         return ret_val;
14012 }
14013
14014 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
14015         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14016         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14017         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14018         return (uint64_t)ret_conv;
14019 }
14020
14021 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
14022         LDKUpdateFulfillHTLC o_conv;
14023         o_conv.inner = (void*)(o & (~1));
14024         o_conv.is_owned = (o & 1) || (o == 0);
14025         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14026         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14027         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14028         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14029         return (uint64_t)ret_conv;
14030 }
14031
14032 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
14033         LDKDecodeError e_conv;
14034         e_conv.inner = (void*)(e & (~1));
14035         e_conv.is_owned = (e & 1) || (e == 0);
14036         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14037         e_conv = DecodeError_clone(&e_conv);
14038         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14039         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14040         return (uint64_t)ret_conv;
14041 }
14042
14043 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
14044         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
14045         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
14046         return ret_val;
14047 }
14048
14049 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
14050         if ((_res & 1) != 0) return;
14051         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14052         CHECK_ACCESS(_res_ptr);
14053         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
14054         FREE((void*)_res);
14055         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14056 }
14057
14058 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
14059         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14060         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
14061         return (uint64_t)ret_conv;
14062 }
14063 int64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14064         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
14065         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
14066         return ret_val;
14067 }
14068
14069 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
14070         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
14071         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14072         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
14073         return (uint64_t)ret_conv;
14074 }
14075
14076 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
14077         LDKUpdateAddHTLC o_conv;
14078         o_conv.inner = (void*)(o & (~1));
14079         o_conv.is_owned = (o & 1) || (o == 0);
14080         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14081         o_conv = UpdateAddHTLC_clone(&o_conv);
14082         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14083         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
14084         return (uint64_t)ret_conv;
14085 }
14086
14087 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
14088         LDKDecodeError e_conv;
14089         e_conv.inner = (void*)(e & (~1));
14090         e_conv.is_owned = (e & 1) || (e == 0);
14091         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14092         e_conv = DecodeError_clone(&e_conv);
14093         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14094         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
14095         return (uint64_t)ret_conv;
14096 }
14097
14098 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
14099         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
14100         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
14101         return ret_val;
14102 }
14103
14104 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
14105         if ((_res & 1) != 0) return;
14106         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14107         CHECK_ACCESS(_res_ptr);
14108         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
14109         FREE((void*)_res);
14110         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
14111 }
14112
14113 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
14114         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14115         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
14116         return (uint64_t)ret_conv;
14117 }
14118 int64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14119         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
14120         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
14121         return ret_val;
14122 }
14123
14124 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
14125         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
14126         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14127         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
14128         return (uint64_t)ret_conv;
14129 }
14130
14131 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
14132         LDKPing o_conv;
14133         o_conv.inner = (void*)(o & (~1));
14134         o_conv.is_owned = (o & 1) || (o == 0);
14135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14136         o_conv = Ping_clone(&o_conv);
14137         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14138         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
14139         return (uint64_t)ret_conv;
14140 }
14141
14142 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
14143         LDKDecodeError e_conv;
14144         e_conv.inner = (void*)(e & (~1));
14145         e_conv.is_owned = (e & 1) || (e == 0);
14146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14147         e_conv = DecodeError_clone(&e_conv);
14148         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14149         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
14150         return (uint64_t)ret_conv;
14151 }
14152
14153 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
14154         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
14155         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
14156         return ret_val;
14157 }
14158
14159 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
14160         if ((_res & 1) != 0) return;
14161         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14162         CHECK_ACCESS(_res_ptr);
14163         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
14164         FREE((void*)_res);
14165         CResult_PingDecodeErrorZ_free(_res_conv);
14166 }
14167
14168 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
14169         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14170         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
14171         return (uint64_t)ret_conv;
14172 }
14173 int64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
14174         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
14175         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
14176         return ret_val;
14177 }
14178
14179 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
14180         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
14181         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14182         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
14183         return (uint64_t)ret_conv;
14184 }
14185
14186 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
14187         LDKPong o_conv;
14188         o_conv.inner = (void*)(o & (~1));
14189         o_conv.is_owned = (o & 1) || (o == 0);
14190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14191         o_conv = Pong_clone(&o_conv);
14192         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14193         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
14194         return (uint64_t)ret_conv;
14195 }
14196
14197 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
14198         LDKDecodeError e_conv;
14199         e_conv.inner = (void*)(e & (~1));
14200         e_conv.is_owned = (e & 1) || (e == 0);
14201         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14202         e_conv = DecodeError_clone(&e_conv);
14203         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14204         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
14205         return (uint64_t)ret_conv;
14206 }
14207
14208 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
14209         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
14210         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
14211         return ret_val;
14212 }
14213
14214 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
14215         if ((_res & 1) != 0) return;
14216         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14217         CHECK_ACCESS(_res_ptr);
14218         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
14219         FREE((void*)_res);
14220         CResult_PongDecodeErrorZ_free(_res_conv);
14221 }
14222
14223 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
14224         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14225         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
14226         return (uint64_t)ret_conv;
14227 }
14228 int64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
14229         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
14230         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
14231         return ret_val;
14232 }
14233
14234 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
14235         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
14236         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14237         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
14238         return (uint64_t)ret_conv;
14239 }
14240
14241 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14242         LDKUnsignedChannelAnnouncement o_conv;
14243         o_conv.inner = (void*)(o & (~1));
14244         o_conv.is_owned = (o & 1) || (o == 0);
14245         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14246         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
14247         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14248         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
14249         return (uint64_t)ret_conv;
14250 }
14251
14252 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14253         LDKDecodeError e_conv;
14254         e_conv.inner = (void*)(e & (~1));
14255         e_conv.is_owned = (e & 1) || (e == 0);
14256         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14257         e_conv = DecodeError_clone(&e_conv);
14258         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14259         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
14260         return (uint64_t)ret_conv;
14261 }
14262
14263 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14264         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
14265         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14266         return ret_val;
14267 }
14268
14269 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14270         if ((_res & 1) != 0) return;
14271         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14272         CHECK_ACCESS(_res_ptr);
14273         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14274         FREE((void*)_res);
14275         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
14276 }
14277
14278 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14279         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14280         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
14281         return (uint64_t)ret_conv;
14282 }
14283 int64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14284         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14285         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14286         return ret_val;
14287 }
14288
14289 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14290         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14292         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14293         return (uint64_t)ret_conv;
14294 }
14295
14296 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14297         LDKChannelAnnouncement o_conv;
14298         o_conv.inner = (void*)(o & (~1));
14299         o_conv.is_owned = (o & 1) || (o == 0);
14300         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14301         o_conv = ChannelAnnouncement_clone(&o_conv);
14302         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14303         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
14304         return (uint64_t)ret_conv;
14305 }
14306
14307 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14308         LDKDecodeError e_conv;
14309         e_conv.inner = (void*)(e & (~1));
14310         e_conv.is_owned = (e & 1) || (e == 0);
14311         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14312         e_conv = DecodeError_clone(&e_conv);
14313         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14314         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
14315         return (uint64_t)ret_conv;
14316 }
14317
14318 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14319         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
14320         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14321         return ret_val;
14322 }
14323
14324 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14325         if ((_res & 1) != 0) return;
14326         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14327         CHECK_ACCESS(_res_ptr);
14328         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14329         FREE((void*)_res);
14330         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
14331 }
14332
14333 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14334         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14335         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
14336         return (uint64_t)ret_conv;
14337 }
14338 int64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14339         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14340         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14341         return ret_val;
14342 }
14343
14344 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14345         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14346         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14347         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14348         return (uint64_t)ret_conv;
14349 }
14350
14351 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14352         LDKUnsignedChannelUpdate o_conv;
14353         o_conv.inner = (void*)(o & (~1));
14354         o_conv.is_owned = (o & 1) || (o == 0);
14355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14356         o_conv = UnsignedChannelUpdate_clone(&o_conv);
14357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14358         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
14359         return (uint64_t)ret_conv;
14360 }
14361
14362 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
14363         LDKDecodeError e_conv;
14364         e_conv.inner = (void*)(e & (~1));
14365         e_conv.is_owned = (e & 1) || (e == 0);
14366         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14367         e_conv = DecodeError_clone(&e_conv);
14368         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14369         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
14370         return (uint64_t)ret_conv;
14371 }
14372
14373 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14374         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
14375         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
14376         return ret_val;
14377 }
14378
14379 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14380         if ((_res & 1) != 0) return;
14381         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14382         CHECK_ACCESS(_res_ptr);
14383         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
14384         FREE((void*)_res);
14385         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
14386 }
14387
14388 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14389         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14390         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
14391         return (uint64_t)ret_conv;
14392 }
14393 int64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14394         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
14395         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14396         return ret_val;
14397 }
14398
14399 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
14401         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14402         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
14403         return (uint64_t)ret_conv;
14404 }
14405
14406 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14407         LDKChannelUpdate o_conv;
14408         o_conv.inner = (void*)(o & (~1));
14409         o_conv.is_owned = (o & 1) || (o == 0);
14410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14411         o_conv = ChannelUpdate_clone(&o_conv);
14412         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14413         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
14414         return (uint64_t)ret_conv;
14415 }
14416
14417 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
14418         LDKDecodeError e_conv;
14419         e_conv.inner = (void*)(e & (~1));
14420         e_conv.is_owned = (e & 1) || (e == 0);
14421         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14422         e_conv = DecodeError_clone(&e_conv);
14423         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14424         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
14425         return (uint64_t)ret_conv;
14426 }
14427
14428 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14429         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
14430         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
14431         return ret_val;
14432 }
14433
14434 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14435         if ((_res & 1) != 0) return;
14436         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14437         CHECK_ACCESS(_res_ptr);
14438         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
14439         FREE((void*)_res);
14440         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
14441 }
14442
14443 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14444         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14445         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
14446         return (uint64_t)ret_conv;
14447 }
14448 int64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14449         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
14450         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14451         return ret_val;
14452 }
14453
14454 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14455         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
14456         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14457         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
14458         return (uint64_t)ret_conv;
14459 }
14460
14461 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
14462         LDKErrorMessage o_conv;
14463         o_conv.inner = (void*)(o & (~1));
14464         o_conv.is_owned = (o & 1) || (o == 0);
14465         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14466         o_conv = ErrorMessage_clone(&o_conv);
14467         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14468         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
14469         return (uint64_t)ret_conv;
14470 }
14471
14472 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
14473         LDKDecodeError e_conv;
14474         e_conv.inner = (void*)(e & (~1));
14475         e_conv.is_owned = (e & 1) || (e == 0);
14476         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14477         e_conv = DecodeError_clone(&e_conv);
14478         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14479         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
14480         return (uint64_t)ret_conv;
14481 }
14482
14483 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
14484         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
14485         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
14486         return ret_val;
14487 }
14488
14489 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
14490         if ((_res & 1) != 0) return;
14491         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14492         CHECK_ACCESS(_res_ptr);
14493         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
14494         FREE((void*)_res);
14495         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
14496 }
14497
14498 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
14499         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14500         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
14501         return (uint64_t)ret_conv;
14502 }
14503 int64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
14504         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
14505         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
14506         return ret_val;
14507 }
14508
14509 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
14510         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
14511         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14512         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
14513         return (uint64_t)ret_conv;
14514 }
14515
14516 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14517         LDKUnsignedNodeAnnouncement o_conv;
14518         o_conv.inner = (void*)(o & (~1));
14519         o_conv.is_owned = (o & 1) || (o == 0);
14520         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14521         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
14522         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14523         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
14524         return (uint64_t)ret_conv;
14525 }
14526
14527 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14528         LDKDecodeError e_conv;
14529         e_conv.inner = (void*)(e & (~1));
14530         e_conv.is_owned = (e & 1) || (e == 0);
14531         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14532         e_conv = DecodeError_clone(&e_conv);
14533         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14534         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
14535         return (uint64_t)ret_conv;
14536 }
14537
14538 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14539         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
14540         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14541         return ret_val;
14542 }
14543
14544 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14545         if ((_res & 1) != 0) return;
14546         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14547         CHECK_ACCESS(_res_ptr);
14548         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
14549         FREE((void*)_res);
14550         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
14551 }
14552
14553 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14554         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14555         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
14556         return (uint64_t)ret_conv;
14557 }
14558 int64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14559         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
14560         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14561         return ret_val;
14562 }
14563
14564 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14565         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
14566         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14567         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
14568         return (uint64_t)ret_conv;
14569 }
14570
14571 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14572         LDKNodeAnnouncement o_conv;
14573         o_conv.inner = (void*)(o & (~1));
14574         o_conv.is_owned = (o & 1) || (o == 0);
14575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14576         o_conv = NodeAnnouncement_clone(&o_conv);
14577         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14578         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
14579         return (uint64_t)ret_conv;
14580 }
14581
14582 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14583         LDKDecodeError e_conv;
14584         e_conv.inner = (void*)(e & (~1));
14585         e_conv.is_owned = (e & 1) || (e == 0);
14586         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14587         e_conv = DecodeError_clone(&e_conv);
14588         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14589         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
14590         return (uint64_t)ret_conv;
14591 }
14592
14593 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14594         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
14595         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14596         return ret_val;
14597 }
14598
14599 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14600         if ((_res & 1) != 0) return;
14601         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14602         CHECK_ACCESS(_res_ptr);
14603         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
14604         FREE((void*)_res);
14605         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
14606 }
14607
14608 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14609         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14610         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
14611         return (uint64_t)ret_conv;
14612 }
14613 int64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14614         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
14615         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14616         return ret_val;
14617 }
14618
14619 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14620         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
14621         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14622         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
14623         return (uint64_t)ret_conv;
14624 }
14625
14626 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
14627         LDKQueryShortChannelIds o_conv;
14628         o_conv.inner = (void*)(o & (~1));
14629         o_conv.is_owned = (o & 1) || (o == 0);
14630         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14631         o_conv = QueryShortChannelIds_clone(&o_conv);
14632         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14633         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
14634         return (uint64_t)ret_conv;
14635 }
14636
14637 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
14638         LDKDecodeError e_conv;
14639         e_conv.inner = (void*)(e & (~1));
14640         e_conv.is_owned = (e & 1) || (e == 0);
14641         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14642         e_conv = DecodeError_clone(&e_conv);
14643         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14644         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
14645         return (uint64_t)ret_conv;
14646 }
14647
14648 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
14649         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
14650         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
14651         return ret_val;
14652 }
14653
14654 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
14655         if ((_res & 1) != 0) return;
14656         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14657         CHECK_ACCESS(_res_ptr);
14658         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
14659         FREE((void*)_res);
14660         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
14661 }
14662
14663 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
14664         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14665         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
14666         return (uint64_t)ret_conv;
14667 }
14668 int64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
14669         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
14670         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
14671         return ret_val;
14672 }
14673
14674 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
14675         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
14676         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14677         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
14678         return (uint64_t)ret_conv;
14679 }
14680
14681 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
14682         LDKReplyShortChannelIdsEnd o_conv;
14683         o_conv.inner = (void*)(o & (~1));
14684         o_conv.is_owned = (o & 1) || (o == 0);
14685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14686         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
14687         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14688         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
14689         return (uint64_t)ret_conv;
14690 }
14691
14692 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
14693         LDKDecodeError e_conv;
14694         e_conv.inner = (void*)(e & (~1));
14695         e_conv.is_owned = (e & 1) || (e == 0);
14696         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14697         e_conv = DecodeError_clone(&e_conv);
14698         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14699         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
14700         return (uint64_t)ret_conv;
14701 }
14702
14703 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
14704         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
14705         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
14706         return ret_val;
14707 }
14708
14709 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
14710         if ((_res & 1) != 0) return;
14711         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14712         CHECK_ACCESS(_res_ptr);
14713         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
14714         FREE((void*)_res);
14715         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
14716 }
14717
14718 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
14719         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14720         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
14721         return (uint64_t)ret_conv;
14722 }
14723 int64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
14724         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
14725         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
14726         return ret_val;
14727 }
14728
14729 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
14730         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
14731         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14732         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
14733         return (uint64_t)ret_conv;
14734 }
14735
14736 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
14737         LDKQueryChannelRange o_conv;
14738         o_conv.inner = (void*)(o & (~1));
14739         o_conv.is_owned = (o & 1) || (o == 0);
14740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14741         o_conv = QueryChannelRange_clone(&o_conv);
14742         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14743         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
14744         return (uint64_t)ret_conv;
14745 }
14746
14747 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
14748         LDKDecodeError e_conv;
14749         e_conv.inner = (void*)(e & (~1));
14750         e_conv.is_owned = (e & 1) || (e == 0);
14751         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14752         e_conv = DecodeError_clone(&e_conv);
14753         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14754         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
14755         return (uint64_t)ret_conv;
14756 }
14757
14758 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14759         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
14760         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
14761         return ret_val;
14762 }
14763
14764 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
14765         if ((_res & 1) != 0) return;
14766         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14767         CHECK_ACCESS(_res_ptr);
14768         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
14769         FREE((void*)_res);
14770         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
14771 }
14772
14773 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14774         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14775         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
14776         return (uint64_t)ret_conv;
14777 }
14778 int64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14779         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
14780         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14781         return ret_val;
14782 }
14783
14784 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14785         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
14786         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14787         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
14788         return (uint64_t)ret_conv;
14789 }
14790
14791 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
14792         LDKReplyChannelRange o_conv;
14793         o_conv.inner = (void*)(o & (~1));
14794         o_conv.is_owned = (o & 1) || (o == 0);
14795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14796         o_conv = ReplyChannelRange_clone(&o_conv);
14797         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14798         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
14799         return (uint64_t)ret_conv;
14800 }
14801
14802 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
14803         LDKDecodeError e_conv;
14804         e_conv.inner = (void*)(e & (~1));
14805         e_conv.is_owned = (e & 1) || (e == 0);
14806         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14807         e_conv = DecodeError_clone(&e_conv);
14808         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14809         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
14810         return (uint64_t)ret_conv;
14811 }
14812
14813 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14814         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
14815         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
14816         return ret_val;
14817 }
14818
14819 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
14820         if ((_res & 1) != 0) return;
14821         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14822         CHECK_ACCESS(_res_ptr);
14823         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
14824         FREE((void*)_res);
14825         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
14826 }
14827
14828 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14829         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14830         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
14831         return (uint64_t)ret_conv;
14832 }
14833 int64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14834         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
14835         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14836         return ret_val;
14837 }
14838
14839 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14840         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
14841         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14842         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
14843         return (uint64_t)ret_conv;
14844 }
14845
14846 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
14847         LDKGossipTimestampFilter o_conv;
14848         o_conv.inner = (void*)(o & (~1));
14849         o_conv.is_owned = (o & 1) || (o == 0);
14850         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14851         o_conv = GossipTimestampFilter_clone(&o_conv);
14852         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14853         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
14854         return (uint64_t)ret_conv;
14855 }
14856
14857 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
14858         LDKDecodeError e_conv;
14859         e_conv.inner = (void*)(e & (~1));
14860         e_conv.is_owned = (e & 1) || (e == 0);
14861         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14862         e_conv = DecodeError_clone(&e_conv);
14863         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14864         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
14865         return (uint64_t)ret_conv;
14866 }
14867
14868 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
14869         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
14870         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
14871         return ret_val;
14872 }
14873
14874 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
14875         if ((_res & 1) != 0) return;
14876         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14877         CHECK_ACCESS(_res_ptr);
14878         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
14879         FREE((void*)_res);
14880         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
14881 }
14882
14883 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
14884         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14885         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
14886         return (uint64_t)ret_conv;
14887 }
14888 int64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
14889         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
14890         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
14891         return ret_val;
14892 }
14893
14894 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
14895         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
14896         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14897         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
14898         return (uint64_t)ret_conv;
14899 }
14900
14901 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14902         LDKDelayedPaymentOutputDescriptor o_conv;
14903         o_conv.inner = (void*)(o & (~1));
14904         o_conv.is_owned = (o & 1) || (o == 0);
14905         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14906         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14907         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14908         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14909         return (uint64_t)ret_conv;
14910 }
14911
14912 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14913         LDKDecodeError e_conv;
14914         e_conv.inner = (void*)(e & (~1));
14915         e_conv.is_owned = (e & 1) || (e == 0);
14916         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14917         e_conv = DecodeError_clone(&e_conv);
14918         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14919         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14920         return (uint64_t)ret_conv;
14921 }
14922
14923 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14924         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14925         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14926         return ret_val;
14927 }
14928
14929 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14930         if ((_res & 1) != 0) return;
14931         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14932         CHECK_ACCESS(_res_ptr);
14933         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14934         FREE((void*)_res);
14935         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14936 }
14937
14938 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14939         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14940         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14941         return (uint64_t)ret_conv;
14942 }
14943 int64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14944         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14945         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14946         return ret_val;
14947 }
14948
14949 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14950         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14951         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14952         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14953         return (uint64_t)ret_conv;
14954 }
14955
14956 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14957         LDKStaticPaymentOutputDescriptor o_conv;
14958         o_conv.inner = (void*)(o & (~1));
14959         o_conv.is_owned = (o & 1) || (o == 0);
14960         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14961         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14962         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14963         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14964         return (uint64_t)ret_conv;
14965 }
14966
14967 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14968         LDKDecodeError e_conv;
14969         e_conv.inner = (void*)(e & (~1));
14970         e_conv.is_owned = (e & 1) || (e == 0);
14971         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14972         e_conv = DecodeError_clone(&e_conv);
14973         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14974         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14975         return (uint64_t)ret_conv;
14976 }
14977
14978 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14979         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14980         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14981         return ret_val;
14982 }
14983
14984 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14985         if ((_res & 1) != 0) return;
14986         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14987         CHECK_ACCESS(_res_ptr);
14988         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14989         FREE((void*)_res);
14990         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14991 }
14992
14993 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14994         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14995         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14996         return (uint64_t)ret_conv;
14997 }
14998 int64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14999         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15000         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15001         return ret_val;
15002 }
15003
15004 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15005         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15006         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15007         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15008         return (uint64_t)ret_conv;
15009 }
15010
15011 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15012         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15013         CHECK_ACCESS(o_ptr);
15014         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15015         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
15016         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15017         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15018         return (uint64_t)ret_conv;
15019 }
15020
15021 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15022         LDKDecodeError e_conv;
15023         e_conv.inner = (void*)(e & (~1));
15024         e_conv.is_owned = (e & 1) || (e == 0);
15025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15026         e_conv = DecodeError_clone(&e_conv);
15027         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15028         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15029         return (uint64_t)ret_conv;
15030 }
15031
15032 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15033         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15034         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15035         return ret_val;
15036 }
15037
15038 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15039         if ((_res & 1) != 0) return;
15040         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15041         CHECK_ACCESS(_res_ptr);
15042         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15043         FREE((void*)_res);
15044         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15045 }
15046
15047 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15048         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15049         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15050         return (uint64_t)ret_conv;
15051 }
15052 int64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15053         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15054         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15055         return ret_val;
15056 }
15057
15058 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15059         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15060         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15061         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15062         return (uint64_t)ret_conv;
15063 }
15064
15065 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15066         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15067         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15068         return ((uint64_t)ret_conv);
15069 }
15070 int64_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15071         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15072         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15073         return ret_val;
15074 }
15075
15076 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15077         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15078         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15079         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15080         return ((uint64_t)ret_conv);
15081 }
15082
15083 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15084         LDKSignature a_ref;
15085         CHECK(a->arr_len == 64);
15086         memcpy(a_ref.compact_form, a->elems, 64);
15087         LDKCVec_SignatureZ b_constr;
15088         b_constr.datalen = b->arr_len;
15089         if (b_constr.datalen > 0)
15090                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15091         else
15092                 b_constr.data = NULL;
15093         int8_tArray* b_vals = (void*) b->elems;
15094         for (size_t m = 0; m < b_constr.datalen; m++) {
15095                 int8_tArray b_conv_12 = b_vals[m];
15096                 LDKSignature b_conv_12_ref;
15097                 CHECK(b_conv_12->arr_len == 64);
15098                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64);
15099                 b_constr.data[m] = b_conv_12_ref;
15100         }
15101         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15102         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15103         return ((uint64_t)ret_conv);
15104 }
15105
15106 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
15107         if ((_res & 1) != 0) return;
15108         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15109         CHECK_ACCESS(_res_ptr);
15110         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15111         FREE((void*)_res);
15112         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15113 }
15114
15115 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15116         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15117         CHECK_ACCESS(o_ptr);
15118         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15119         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
15120         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15121         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15122         return (uint64_t)ret_conv;
15123 }
15124
15125 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15126         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15127         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15128         return (uint64_t)ret_conv;
15129 }
15130
15131 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15132         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15133         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15134         return ret_val;
15135 }
15136
15137 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15138         if ((_res & 1) != 0) return;
15139         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15140         CHECK_ACCESS(_res_ptr);
15141         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15142         FREE((void*)_res);
15143         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15144 }
15145
15146 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15147         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15148         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15149         return (uint64_t)ret_conv;
15150 }
15151 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15152         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15153         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15154         return ret_val;
15155 }
15156
15157 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15158         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15159         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15160         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15161         return (uint64_t)ret_conv;
15162 }
15163
15164 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15165         LDKSignature o_ref;
15166         CHECK(o->arr_len == 64);
15167         memcpy(o_ref.compact_form, o->elems, 64);
15168         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15169         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15170         return (uint64_t)ret_conv;
15171 }
15172
15173 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15174         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15175         *ret_conv = CResult_SignatureNoneZ_err();
15176         return (uint64_t)ret_conv;
15177 }
15178
15179 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15180         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15181         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
15182         return ret_val;
15183 }
15184
15185 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15186         if ((_res & 1) != 0) return;
15187         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15188         CHECK_ACCESS(_res_ptr);
15189         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15190         FREE((void*)_res);
15191         CResult_SignatureNoneZ_free(_res_conv);
15192 }
15193
15194 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15195         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15196         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15197         return (uint64_t)ret_conv;
15198 }
15199 int64_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15200         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15201         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15202         return ret_val;
15203 }
15204
15205 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15206         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15207         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15208         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15209         return (uint64_t)ret_conv;
15210 }
15211
15212 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15213         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15214         CHECK_ACCESS(o_ptr);
15215         LDKSign o_conv = *(LDKSign*)(o_ptr);
15216         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15217         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15218         return (uint64_t)ret_conv;
15219 }
15220
15221 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15222         LDKDecodeError e_conv;
15223         e_conv.inner = (void*)(e & (~1));
15224         e_conv.is_owned = (e & 1) || (e == 0);
15225         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15226         e_conv = DecodeError_clone(&e_conv);
15227         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15228         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15229         return (uint64_t)ret_conv;
15230 }
15231
15232 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15233         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15234         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
15235         return ret_val;
15236 }
15237
15238 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15239         if ((_res & 1) != 0) return;
15240         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15241         CHECK_ACCESS(_res_ptr);
15242         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15243         FREE((void*)_res);
15244         CResult_SignDecodeErrorZ_free(_res_conv);
15245 }
15246
15247 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15248         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15249         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15250         return (uint64_t)ret_conv;
15251 }
15252 int64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15253         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15254         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15255         return ret_val;
15256 }
15257
15258 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15259         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15260         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15261         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15262         return (uint64_t)ret_conv;
15263 }
15264
15265 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15266         LDKRecoverableSignature o_ref;
15267         CHECK(o->arr_len == 68);
15268         memcpy(o_ref.serialized_form, o->elems, 68);
15269         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15270         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15271         return (uint64_t)ret_conv;
15272 }
15273
15274 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15275         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15276         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15277         return (uint64_t)ret_conv;
15278 }
15279
15280 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15281         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15282         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15283         return ret_val;
15284 }
15285
15286 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15287         if ((_res & 1) != 0) return;
15288         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15289         CHECK_ACCESS(_res_ptr);
15290         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15291         FREE((void*)_res);
15292         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15293 }
15294
15295 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15296         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15297         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15298         return (uint64_t)ret_conv;
15299 }
15300 int64_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15301         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15302         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15303         return ret_val;
15304 }
15305
15306 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15307         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15308         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15309         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15310         return (uint64_t)ret_conv;
15311 }
15312
15313 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15314         LDKCVec_CVec_u8ZZ _res_constr;
15315         _res_constr.datalen = _res->arr_len;
15316         if (_res_constr.datalen > 0)
15317                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15318         else
15319                 _res_constr.data = NULL;
15320         int8_tArray* _res_vals = (void*) _res->elems;
15321         for (size_t m = 0; m < _res_constr.datalen; m++) {
15322                 int8_tArray _res_conv_12 = _res_vals[m];
15323                 LDKCVec_u8Z _res_conv_12_ref;
15324                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15325                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15326                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen);
15327                 _res_constr.data[m] = _res_conv_12_ref;
15328         }
15329         CVec_CVec_u8ZZ_free(_res_constr);
15330 }
15331
15332 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15333         LDKCVec_CVec_u8ZZ o_constr;
15334         o_constr.datalen = o->arr_len;
15335         if (o_constr.datalen > 0)
15336                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15337         else
15338                 o_constr.data = NULL;
15339         int8_tArray* o_vals = (void*) o->elems;
15340         for (size_t m = 0; m < o_constr.datalen; m++) {
15341                 int8_tArray o_conv_12 = o_vals[m];
15342                 LDKCVec_u8Z o_conv_12_ref;
15343                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15344                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15345                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen);
15346                 o_constr.data[m] = o_conv_12_ref;
15347         }
15348         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15349         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15350         return (uint64_t)ret_conv;
15351 }
15352
15353 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15354         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15355         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15356         return (uint64_t)ret_conv;
15357 }
15358
15359 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15360         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15361         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15362         return ret_val;
15363 }
15364
15365 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15366         if ((_res & 1) != 0) return;
15367         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15368         CHECK_ACCESS(_res_ptr);
15369         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15370         FREE((void*)_res);
15371         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15372 }
15373
15374 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15375         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15376         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15377         return (uint64_t)ret_conv;
15378 }
15379 int64_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15380         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15381         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15382         return ret_val;
15383 }
15384
15385 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15386         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15387         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15388         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15389         return (uint64_t)ret_conv;
15390 }
15391
15392 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15393         LDKInMemorySigner o_conv;
15394         o_conv.inner = (void*)(o & (~1));
15395         o_conv.is_owned = (o & 1) || (o == 0);
15396         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15397         o_conv = InMemorySigner_clone(&o_conv);
15398         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15399         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15400         return (uint64_t)ret_conv;
15401 }
15402
15403 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15404         LDKDecodeError e_conv;
15405         e_conv.inner = (void*)(e & (~1));
15406         e_conv.is_owned = (e & 1) || (e == 0);
15407         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15408         e_conv = DecodeError_clone(&e_conv);
15409         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15410         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15411         return (uint64_t)ret_conv;
15412 }
15413
15414 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15415         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15416         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15417         return ret_val;
15418 }
15419
15420 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15421         if ((_res & 1) != 0) return;
15422         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15423         CHECK_ACCESS(_res_ptr);
15424         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15425         FREE((void*)_res);
15426         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15427 }
15428
15429 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15430         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15431         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15432         return (uint64_t)ret_conv;
15433 }
15434 int64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15435         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15436         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15437         return ret_val;
15438 }
15439
15440 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15441         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15442         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15443         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15444         return (uint64_t)ret_conv;
15445 }
15446
15447 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15448         LDKCVec_TxOutZ _res_constr;
15449         _res_constr.datalen = _res->arr_len;
15450         if (_res_constr.datalen > 0)
15451                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15452         else
15453                 _res_constr.data = NULL;
15454         uint32_t* _res_vals = _res->elems;
15455         for (size_t h = 0; h < _res_constr.datalen; h++) {
15456                 uint32_t _res_conv_7 = _res_vals[h];
15457                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
15458                 CHECK_ACCESS(_res_conv_7_ptr);
15459                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15460                 FREE((void*)_res_conv_7);
15461                 _res_constr.data[h] = _res_conv_7_conv;
15462         }
15463         CVec_TxOutZ_free(_res_constr);
15464 }
15465
15466 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15467         LDKTransaction o_ref;
15468         o_ref.datalen = o->arr_len;
15469         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15470         memcpy(o_ref.data, o->elems, o_ref.datalen);
15471         o_ref.data_is_owned = true;
15472         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15473         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15474         return (uint64_t)ret_conv;
15475 }
15476
15477 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15478         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15479         *ret_conv = CResult_TransactionNoneZ_err();
15480         return (uint64_t)ret_conv;
15481 }
15482
15483 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15484         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15485         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
15486         return ret_val;
15487 }
15488
15489 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15490         if ((_res & 1) != 0) return;
15491         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15492         CHECK_ACCESS(_res_ptr);
15493         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15494         FREE((void*)_res);
15495         CResult_TransactionNoneZ_free(_res_conv);
15496 }
15497
15498 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15499         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15500         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15501         return (uint64_t)ret_conv;
15502 }
15503 int64_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15504         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15505         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15506         return ret_val;
15507 }
15508
15509 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15510         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15511         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15512         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15513         return (uint64_t)ret_conv;
15514 }
15515
15516 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
15517         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15518         CHECK_ACCESS(o_ptr);
15519         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
15520         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15521         *ret_copy = COption_FilterZ_some(o_conv);
15522         uint64_t ret_ref = (uint64_t)ret_copy;
15523         return ret_ref;
15524 }
15525
15526 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
15527         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15528         *ret_copy = COption_FilterZ_none();
15529         uint64_t ret_ref = (uint64_t)ret_copy;
15530         return ret_ref;
15531 }
15532
15533 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
15534         if ((_res & 1) != 0) return;
15535         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15536         CHECK_ACCESS(_res_ptr);
15537         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
15538         FREE((void*)_res);
15539         COption_FilterZ_free(_res_conv);
15540 }
15541
15542 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
15543         LDKLockedChannelMonitor o_conv;
15544         o_conv.inner = (void*)(o & (~1));
15545         o_conv.is_owned = (o & 1) || (o == 0);
15546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15547         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15548         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15549         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15550         return (uint64_t)ret_conv;
15551 }
15552
15553 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
15554         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15555         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15556         return (uint64_t)ret_conv;
15557 }
15558
15559 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
15560         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
15561         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
15562         return ret_val;
15563 }
15564
15565 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
15566         if ((_res & 1) != 0) return;
15567         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15568         CHECK_ACCESS(_res_ptr);
15569         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
15570         FREE((void*)_res);
15571         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15572 }
15573
15574 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
15575         LDKCVec_OutPointZ _res_constr;
15576         _res_constr.datalen = _res->arr_len;
15577         if (_res_constr.datalen > 0)
15578                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15579         else
15580                 _res_constr.data = NULL;
15581         uint32_t* _res_vals = _res->elems;
15582         for (size_t k = 0; k < _res_constr.datalen; k++) {
15583                 uint32_t _res_conv_10 = _res_vals[k];
15584                 LDKOutPoint _res_conv_10_conv;
15585                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15586                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15587                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15588                 _res_constr.data[k] = _res_conv_10_conv;
15589         }
15590         CVec_OutPointZ_free(_res_constr);
15591 }
15592
15593 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15594         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15595         *ret_conv = CResult_NoneAPIErrorZ_ok();
15596         return (uint64_t)ret_conv;
15597 }
15598
15599 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15600         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15601         CHECK_ACCESS(e_ptr);
15602         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15603         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
15604         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15605         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15606         return (uint64_t)ret_conv;
15607 }
15608
15609 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15610         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15611         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
15612         return ret_val;
15613 }
15614
15615 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15616         if ((_res & 1) != 0) return;
15617         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15618         CHECK_ACCESS(_res_ptr);
15619         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15620         FREE((void*)_res);
15621         CResult_NoneAPIErrorZ_free(_res_conv);
15622 }
15623
15624 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15625         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15626         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15627         return (uint64_t)ret_conv;
15628 }
15629 int64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15630         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15631         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15632         return ret_val;
15633 }
15634
15635 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15636         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15637         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15638         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15639         return (uint64_t)ret_conv;
15640 }
15641
15642 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15643         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15644         *ret_copy = COption_u16Z_some(o);
15645         uint64_t ret_ref = (uint64_t)ret_copy;
15646         return ret_ref;
15647 }
15648
15649 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15650         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15651         *ret_copy = COption_u16Z_none();
15652         uint64_t ret_ref = (uint64_t)ret_copy;
15653         return ret_ref;
15654 }
15655
15656 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15657         if ((_res & 1) != 0) return;
15658         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15659         CHECK_ACCESS(_res_ptr);
15660         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15661         FREE((void*)_res);
15662         COption_u16Z_free(_res_conv);
15663 }
15664
15665 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15666         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15667         *ret_copy = COption_u16Z_clone(arg);
15668 uint64_t ret_ref = (uint64_t)ret_copy;
15669         return ret_ref;
15670 }
15671 int64_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15672         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15673         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
15674         return ret_val;
15675 }
15676
15677 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15678         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15679         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15680         *ret_copy = COption_u16Z_clone(orig_conv);
15681         uint64_t ret_ref = (uint64_t)ret_copy;
15682         return ret_ref;
15683 }
15684
15685 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15686         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15687         _res_constr.datalen = _res->arr_len;
15688         if (_res_constr.datalen > 0)
15689                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15690         else
15691                 _res_constr.data = NULL;
15692         uint32_t* _res_vals = _res->elems;
15693         for (size_t w = 0; w < _res_constr.datalen; w++) {
15694                 uint32_t _res_conv_22 = _res_vals[w];
15695                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
15696                 CHECK_ACCESS(_res_conv_22_ptr);
15697                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15698                 FREE((void*)_res_conv_22);
15699                 _res_constr.data[w] = _res_conv_22_conv;
15700         }
15701         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15702 }
15703
15704 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15705         LDKCVec_APIErrorZ _res_constr;
15706         _res_constr.datalen = _res->arr_len;
15707         if (_res_constr.datalen > 0)
15708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15709         else
15710                 _res_constr.data = NULL;
15711         uint32_t* _res_vals = _res->elems;
15712         for (size_t k = 0; k < _res_constr.datalen; k++) {
15713                 uint32_t _res_conv_10 = _res_vals[k];
15714                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
15715                 CHECK_ACCESS(_res_conv_10_ptr);
15716                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15717                 FREE((void*)_res_conv_10);
15718                 _res_constr.data[k] = _res_conv_10_conv;
15719         }
15720         CVec_APIErrorZ_free(_res_constr);
15721 }
15722
15723 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15724         LDKThirtyTwoBytes o_ref;
15725         CHECK(o->arr_len == 32);
15726         memcpy(o_ref.data, o->elems, 32);
15727         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15728         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15729         return (uint64_t)ret_conv;
15730 }
15731
15732 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15733         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15734         CHECK_ACCESS(e_ptr);
15735         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15736         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
15737         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15738         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15739         return (uint64_t)ret_conv;
15740 }
15741
15742 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15743         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15744         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
15745         return ret_val;
15746 }
15747
15748 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15749         if ((_res & 1) != 0) return;
15750         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15751         CHECK_ACCESS(_res_ptr);
15752         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15753         FREE((void*)_res);
15754         CResult__u832APIErrorZ_free(_res_conv);
15755 }
15756
15757 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15758         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15759         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15760         return (uint64_t)ret_conv;
15761 }
15762 int64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15763         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15764         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15765         return ret_val;
15766 }
15767
15768 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15769         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15770         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15771         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15772         return (uint64_t)ret_conv;
15773 }
15774
15775 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15776         LDKThirtyTwoBytes o_ref;
15777         CHECK(o->arr_len == 32);
15778         memcpy(o_ref.data, o->elems, 32);
15779         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15780         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15781         return (uint64_t)ret_conv;
15782 }
15783
15784 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15785         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15786         CHECK_ACCESS(e_ptr);
15787         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15788         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
15789         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15790         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15791         return (uint64_t)ret_conv;
15792 }
15793
15794 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15795         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15796         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15797         return ret_val;
15798 }
15799
15800 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15801         if ((_res & 1) != 0) return;
15802         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15803         CHECK_ACCESS(_res_ptr);
15804         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15805         FREE((void*)_res);
15806         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15807 }
15808
15809 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15810         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15811         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15812         return (uint64_t)ret_conv;
15813 }
15814 int64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15815         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15816         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15817         return ret_val;
15818 }
15819
15820 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15821         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15822         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15823         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15824         return (uint64_t)ret_conv;
15825 }
15826
15827 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15828         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15829         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15830         return (uint64_t)ret_conv;
15831 }
15832
15833 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15834         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15835         CHECK_ACCESS(e_ptr);
15836         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15837         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
15838         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15839         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15840         return (uint64_t)ret_conv;
15841 }
15842
15843 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15844         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15845         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15846         return ret_val;
15847 }
15848
15849 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15850         if ((_res & 1) != 0) return;
15851         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15852         CHECK_ACCESS(_res_ptr);
15853         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15854         FREE((void*)_res);
15855         CResult_NonePaymentSendFailureZ_free(_res_conv);
15856 }
15857
15858 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15859         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15860         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15861         return (uint64_t)ret_conv;
15862 }
15863 int64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15864         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15865         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15866         return ret_val;
15867 }
15868
15869 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15870         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15871         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15872         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15873         return (uint64_t)ret_conv;
15874 }
15875
15876 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15877         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15878         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15879         return ((uint64_t)ret_conv);
15880 }
15881 int64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15882         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15883         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15884         return ret_val;
15885 }
15886
15887 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15888         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15889         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15890         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15891         return ((uint64_t)ret_conv);
15892 }
15893
15894 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15895         LDKThirtyTwoBytes a_ref;
15896         CHECK(a->arr_len == 32);
15897         memcpy(a_ref.data, a->elems, 32);
15898         LDKThirtyTwoBytes b_ref;
15899         CHECK(b->arr_len == 32);
15900         memcpy(b_ref.data, b->elems, 32);
15901         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15902         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15903         return ((uint64_t)ret_conv);
15904 }
15905
15906 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15907         if ((_res & 1) != 0) return;
15908         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15909         CHECK_ACCESS(_res_ptr);
15910         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15911         FREE((void*)_res);
15912         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15913 }
15914
15915 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15916         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15917         CHECK_ACCESS(o_ptr);
15918         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15919         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
15920         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15921         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15922         return (uint64_t)ret_conv;
15923 }
15924
15925 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15926         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15927         CHECK_ACCESS(e_ptr);
15928         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15929         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
15930         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15931         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15932         return (uint64_t)ret_conv;
15933 }
15934
15935 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15936         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15937         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15938         return ret_val;
15939 }
15940
15941 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15942         if ((_res & 1) != 0) return;
15943         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15944         CHECK_ACCESS(_res_ptr);
15945         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15946         FREE((void*)_res);
15947         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15948 }
15949
15950 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15951         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15952         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15953         return (uint64_t)ret_conv;
15954 }
15955 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15956         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15957         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15958         return ret_val;
15959 }
15960
15961 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15962         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15963         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15964         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15965         return (uint64_t)ret_conv;
15966 }
15967
15968 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15969         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15970         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15971         return ((uint64_t)ret_conv);
15972 }
15973 int64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15974         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15975         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15976         return ret_val;
15977 }
15978
15979 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15980         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15981         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15982         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15983         return ((uint64_t)ret_conv);
15984 }
15985
15986 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
15987         LDKThirtyTwoBytes a_ref;
15988         CHECK(a->arr_len == 32);
15989         memcpy(a_ref.data, a->elems, 32);
15990         LDKThirtyTwoBytes b_ref;
15991         CHECK(b->arr_len == 32);
15992         memcpy(b_ref.data, b->elems, 32);
15993         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15994         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
15995         return ((uint64_t)ret_conv);
15996 }
15997
15998 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
15999         if ((_res & 1) != 0) return;
16000         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16001         CHECK_ACCESS(_res_ptr);
16002         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16003         FREE((void*)_res);
16004         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16005 }
16006
16007 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16008         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16009         CHECK_ACCESS(o_ptr);
16010         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16011         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
16012         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16013         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16014         return (uint64_t)ret_conv;
16015 }
16016
16017 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16018         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16019         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16020         return (uint64_t)ret_conv;
16021 }
16022
16023 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16025         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16026         return ret_val;
16027 }
16028
16029 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16030         if ((_res & 1) != 0) return;
16031         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16032         CHECK_ACCESS(_res_ptr);
16033         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16034         FREE((void*)_res);
16035         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16036 }
16037
16038 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16039         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16040         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16041         return (uint64_t)ret_conv;
16042 }
16043 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16044         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16045         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16046         return ret_val;
16047 }
16048
16049 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16050         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16051         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16052         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16053         return (uint64_t)ret_conv;
16054 }
16055
16056 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16057         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16058         CHECK_ACCESS(o_ptr);
16059         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16060         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
16061         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16062         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16063         return (uint64_t)ret_conv;
16064 }
16065
16066 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16067         void* e_ptr = (void*)(((uint64_t)e) & ~1);
16068         CHECK_ACCESS(e_ptr);
16069         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16070         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
16071         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16072         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16073         return (uint64_t)ret_conv;
16074 }
16075
16076 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16077         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16078         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16079         return ret_val;
16080 }
16081
16082 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16083         if ((_res & 1) != 0) return;
16084         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16085         CHECK_ACCESS(_res_ptr);
16086         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16087         FREE((void*)_res);
16088         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16089 }
16090
16091 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16092         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16093         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16094         return (uint64_t)ret_conv;
16095 }
16096 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16097         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16098         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16099         return ret_val;
16100 }
16101
16102 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16103         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16104         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16105         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16106         return (uint64_t)ret_conv;
16107 }
16108
16109 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16110         LDKThirtyTwoBytes o_ref;
16111         CHECK(o->arr_len == 32);
16112         memcpy(o_ref.data, o->elems, 32);
16113         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16114         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16115         return (uint64_t)ret_conv;
16116 }
16117
16118 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16119         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16120         *ret_conv = CResult_PaymentSecretNoneZ_err();
16121         return (uint64_t)ret_conv;
16122 }
16123
16124 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16125         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16126         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16127         return ret_val;
16128 }
16129
16130 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16131         if ((_res & 1) != 0) return;
16132         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16133         CHECK_ACCESS(_res_ptr);
16134         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16135         FREE((void*)_res);
16136         CResult_PaymentSecretNoneZ_free(_res_conv);
16137 }
16138
16139 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16140         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16141         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16142         return (uint64_t)ret_conv;
16143 }
16144 int64_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16145         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16146         int64_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16147         return ret_val;
16148 }
16149
16150 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16151         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16152         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16153         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16154         return (uint64_t)ret_conv;
16155 }
16156
16157 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16158         LDKThirtyTwoBytes o_ref;
16159         CHECK(o->arr_len == 32);
16160         memcpy(o_ref.data, o->elems, 32);
16161         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16162         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16163         return (uint64_t)ret_conv;
16164 }
16165
16166 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16167         void* e_ptr = (void*)(((uint64_t)e) & ~1);
16168         CHECK_ACCESS(e_ptr);
16169         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16170         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
16171         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16172         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16173         return (uint64_t)ret_conv;
16174 }
16175
16176 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16177         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16178         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16179         return ret_val;
16180 }
16181
16182 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16183         if ((_res & 1) != 0) return;
16184         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16185         CHECK_ACCESS(_res_ptr);
16186         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16187         FREE((void*)_res);
16188         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16189 }
16190
16191 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16192         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16193         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16194         return (uint64_t)ret_conv;
16195 }
16196 int64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16197         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16198         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16199         return ret_val;
16200 }
16201
16202 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16203         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16204         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16205         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16206         return (uint64_t)ret_conv;
16207 }
16208
16209 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16210         LDKThirtyTwoBytes o_ref;
16211         CHECK(o->arr_len == 32);
16212         memcpy(o_ref.data, o->elems, 32);
16213         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16214         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16215         return (uint64_t)ret_conv;
16216 }
16217
16218 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16219         void* e_ptr = (void*)(((uint64_t)e) & ~1);
16220         CHECK_ACCESS(e_ptr);
16221         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16222         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
16223         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16224         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16225         return (uint64_t)ret_conv;
16226 }
16227
16228 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16229         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16230         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16231         return ret_val;
16232 }
16233
16234 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16235         if ((_res & 1) != 0) return;
16236         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16237         CHECK_ACCESS(_res_ptr);
16238         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16239         FREE((void*)_res);
16240         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16241 }
16242
16243 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16244         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16245         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16246         return (uint64_t)ret_conv;
16247 }
16248 int64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16249         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16250         int64_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16251         return ret_val;
16252 }
16253
16254 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16255         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16256         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16257         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16258         return (uint64_t)ret_conv;
16259 }
16260
16261 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16262         LDKCVec_ChannelMonitorZ _res_constr;
16263         _res_constr.datalen = _res->arr_len;
16264         if (_res_constr.datalen > 0)
16265                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16266         else
16267                 _res_constr.data = NULL;
16268         uint32_t* _res_vals = _res->elems;
16269         for (size_t q = 0; q < _res_constr.datalen; q++) {
16270                 uint32_t _res_conv_16 = _res_vals[q];
16271                 LDKChannelMonitor _res_conv_16_conv;
16272                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16273                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16274                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16275                 _res_constr.data[q] = _res_conv_16_conv;
16276         }
16277         CVec_ChannelMonitorZ_free(_res_constr);
16278 }
16279
16280 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16281         LDKThirtyTwoBytes a_ref;
16282         CHECK(a->arr_len == 32);
16283         memcpy(a_ref.data, a->elems, 32);
16284         LDKChannelManager b_conv;
16285         b_conv.inner = (void*)(b & (~1));
16286         b_conv.is_owned = (b & 1) || (b == 0);
16287         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16288         // Warning: we need a move here but no clone is available for LDKChannelManager
16289         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16290         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16291         return ((uint64_t)ret_conv);
16292 }
16293
16294 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16295         if ((_res & 1) != 0) return;
16296         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16297         CHECK_ACCESS(_res_ptr);
16298         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16299         FREE((void*)_res);
16300         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16301 }
16302
16303 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16304         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16305         CHECK_ACCESS(o_ptr);
16306         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16307         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16308         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16309         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16310         return (uint64_t)ret_conv;
16311 }
16312
16313 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16314         LDKDecodeError e_conv;
16315         e_conv.inner = (void*)(e & (~1));
16316         e_conv.is_owned = (e & 1) || (e == 0);
16317         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16318         e_conv = DecodeError_clone(&e_conv);
16319         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16320         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16321         return (uint64_t)ret_conv;
16322 }
16323
16324 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16325         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16326         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16327         return ret_val;
16328 }
16329
16330 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16331         if ((_res & 1) != 0) return;
16332         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16333         CHECK_ACCESS(_res_ptr);
16334         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16335         FREE((void*)_res);
16336         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16337 }
16338
16339 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
16340         if ((this_ptr & 1) != 0) return;
16341         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16342         CHECK_ACCESS(this_ptr_ptr);
16343         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
16344         FREE((void*)this_ptr);
16345         PaymentPurpose_free(this_ptr_conv);
16346 }
16347
16348 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
16349         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16350         *ret_copy = PaymentPurpose_clone(arg);
16351 uint64_t ret_ref = (uint64_t)ret_copy;
16352         return ret_ref;
16353 }
16354 int64_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
16355         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
16356         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
16357         return ret_val;
16358 }
16359
16360 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
16361         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
16362         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16363         *ret_copy = PaymentPurpose_clone(orig_conv);
16364         uint64_t ret_ref = (uint64_t)ret_copy;
16365         return ret_ref;
16366 }
16367
16368 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
16369         LDKThirtyTwoBytes payment_preimage_ref;
16370         CHECK(payment_preimage->arr_len == 32);
16371         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32);
16372         LDKThirtyTwoBytes payment_secret_ref;
16373         CHECK(payment_secret->arr_len == 32);
16374         memcpy(payment_secret_ref.data, payment_secret->elems, 32);
16375         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16376         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
16377         uint64_t ret_ref = (uint64_t)ret_copy;
16378         return ret_ref;
16379 }
16380
16381 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
16382         LDKThirtyTwoBytes a_ref;
16383         CHECK(a->arr_len == 32);
16384         memcpy(a_ref.data, a->elems, 32);
16385         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16386         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
16387         uint64_t ret_ref = (uint64_t)ret_copy;
16388         return ret_ref;
16389 }
16390
16391 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
16392         if ((this_ptr & 1) != 0) return;
16393         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16394         CHECK_ACCESS(this_ptr_ptr);
16395         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
16396         FREE((void*)this_ptr);
16397         ClosureReason_free(this_ptr_conv);
16398 }
16399
16400 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
16401         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16402         *ret_copy = ClosureReason_clone(arg);
16403 uint64_t ret_ref = (uint64_t)ret_copy;
16404         return ret_ref;
16405 }
16406 int64_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
16407         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
16408         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
16409         return ret_val;
16410 }
16411
16412 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
16413         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
16414         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16415         *ret_copy = ClosureReason_clone(orig_conv);
16416         uint64_t ret_ref = (uint64_t)ret_copy;
16417         return ret_ref;
16418 }
16419
16420 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
16421         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
16422         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16423         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
16424         uint64_t ret_ref = (uint64_t)ret_copy;
16425         return ret_ref;
16426 }
16427
16428 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
16429         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16430         *ret_copy = ClosureReason_holder_force_closed();
16431         uint64_t ret_ref = (uint64_t)ret_copy;
16432         return ret_ref;
16433 }
16434
16435 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
16436         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16437         *ret_copy = ClosureReason_cooperative_closure();
16438         uint64_t ret_ref = (uint64_t)ret_copy;
16439         return ret_ref;
16440 }
16441
16442 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
16443         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16444         *ret_copy = ClosureReason_commitment_tx_confirmed();
16445         uint64_t ret_ref = (uint64_t)ret_copy;
16446         return ret_ref;
16447 }
16448
16449 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
16450         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16451         *ret_copy = ClosureReason_funding_timed_out();
16452         uint64_t ret_ref = (uint64_t)ret_copy;
16453         return ret_ref;
16454 }
16455
16456 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
16457         LDKStr err_conv = str_ref_to_owned_c(err);
16458         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16459         *ret_copy = ClosureReason_processing_error(err_conv);
16460         uint64_t ret_ref = (uint64_t)ret_copy;
16461         return ret_ref;
16462 }
16463
16464 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
16465         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16466         *ret_copy = ClosureReason_disconnected_peer();
16467         uint64_t ret_ref = (uint64_t)ret_copy;
16468         return ret_ref;
16469 }
16470
16471 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
16472         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16473         *ret_copy = ClosureReason_outdated_channel_manager();
16474         uint64_t ret_ref = (uint64_t)ret_copy;
16475         return ret_ref;
16476 }
16477
16478 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
16479         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
16480         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
16481         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
16482         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16483         CVec_u8Z_free(ret_var);
16484         return ret_arr;
16485 }
16486
16487 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
16488         LDKu8slice ser_ref;
16489         ser_ref.datalen = ser->arr_len;
16490         ser_ref.data = ser->elems;
16491         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16492         *ret_conv = ClosureReason_read(ser_ref);
16493         return (uint64_t)ret_conv;
16494 }
16495
16496 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
16497         if ((this_ptr & 1) != 0) return;
16498         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16499         CHECK_ACCESS(this_ptr_ptr);
16500         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
16501         FREE((void*)this_ptr);
16502         Event_free(this_ptr_conv);
16503 }
16504
16505 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
16506         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16507         *ret_copy = Event_clone(arg);
16508 uint64_t ret_ref = (uint64_t)ret_copy;
16509         return ret_ref;
16510 }
16511 int64_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
16512         LDKEvent* arg_conv = (LDKEvent*)arg;
16513         int64_t ret_val = Event_clone_ptr(arg_conv);
16514         return ret_val;
16515 }
16516
16517 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
16518         LDKEvent* orig_conv = (LDKEvent*)orig;
16519         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16520         *ret_copy = Event_clone(orig_conv);
16521         uint64_t ret_ref = (uint64_t)ret_copy;
16522         return ret_ref;
16523 }
16524
16525 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) {
16526         LDKThirtyTwoBytes temporary_channel_id_ref;
16527         CHECK(temporary_channel_id->arr_len == 32);
16528         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32);
16529         LDKCVec_u8Z output_script_ref;
16530         output_script_ref.datalen = output_script->arr_len;
16531         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
16532         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen);
16533         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16534         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
16535         uint64_t ret_ref = (uint64_t)ret_copy;
16536         return ret_ref;
16537 }
16538
16539 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
16540         LDKThirtyTwoBytes payment_hash_ref;
16541         CHECK(payment_hash->arr_len == 32);
16542         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
16543         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
16544         CHECK_ACCESS(purpose_ptr);
16545         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
16546         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
16547         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16548         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
16549         uint64_t ret_ref = (uint64_t)ret_copy;
16550         return ret_ref;
16551 }
16552
16553 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) {
16554         LDKThirtyTwoBytes payment_id_ref;
16555         CHECK(payment_id->arr_len == 32);
16556         memcpy(payment_id_ref.data, payment_id->elems, 32);
16557         LDKThirtyTwoBytes payment_preimage_ref;
16558         CHECK(payment_preimage->arr_len == 32);
16559         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32);
16560         LDKThirtyTwoBytes payment_hash_ref;
16561         CHECK(payment_hash->arr_len == 32);
16562         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
16563         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
16564         CHECK_ACCESS(fee_paid_msat_ptr);
16565         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
16566         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
16567         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16568         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
16569         uint64_t ret_ref = (uint64_t)ret_copy;
16570         return ret_ref;
16571 }
16572
16573 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) {
16574         LDKThirtyTwoBytes payment_id_ref;
16575         CHECK(payment_id->arr_len == 32);
16576         memcpy(payment_id_ref.data, payment_id->elems, 32);
16577         LDKThirtyTwoBytes payment_hash_ref;
16578         CHECK(payment_hash->arr_len == 32);
16579         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
16580         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
16581         CHECK_ACCESS(network_update_ptr);
16582         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
16583         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
16584         LDKCVec_RouteHopZ path_constr;
16585         path_constr.datalen = path->arr_len;
16586         if (path_constr.datalen > 0)
16587                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16588         else
16589                 path_constr.data = NULL;
16590         uint32_t* path_vals = path->elems;
16591         for (size_t k = 0; k < path_constr.datalen; k++) {
16592                 uint32_t path_conv_10 = path_vals[k];
16593                 LDKRouteHop path_conv_10_conv;
16594                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16595                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16596                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16597                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16598                 path_constr.data[k] = path_conv_10_conv;
16599         }
16600         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
16601         CHECK_ACCESS(short_channel_id_ptr);
16602         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16603         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
16604         LDKRouteParameters retry_conv;
16605         retry_conv.inner = (void*)(retry & (~1));
16606         retry_conv.is_owned = (retry & 1) || (retry == 0);
16607         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
16608         retry_conv = RouteParameters_clone(&retry_conv);
16609         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16610         *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);
16611         uint64_t ret_ref = (uint64_t)ret_copy;
16612         return ret_ref;
16613 }
16614
16615 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
16616         LDKThirtyTwoBytes payment_id_ref;
16617         CHECK(payment_id->arr_len == 32);
16618         memcpy(payment_id_ref.data, payment_id->elems, 32);
16619         LDKThirtyTwoBytes payment_hash_ref;
16620         CHECK(payment_hash->arr_len == 32);
16621         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
16622         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16623         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
16624         uint64_t ret_ref = (uint64_t)ret_copy;
16625         return ret_ref;
16626 }
16627
16628 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
16629         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16630         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16631         uint64_t ret_ref = (uint64_t)ret_copy;
16632         return ret_ref;
16633 }
16634
16635 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
16636         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16637         outputs_constr.datalen = outputs->arr_len;
16638         if (outputs_constr.datalen > 0)
16639                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16640         else
16641                 outputs_constr.data = NULL;
16642         uint32_t* outputs_vals = outputs->elems;
16643         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16644                 uint32_t outputs_conv_27 = outputs_vals[b];
16645                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
16646                 CHECK_ACCESS(outputs_conv_27_ptr);
16647                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16648                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
16649                 outputs_constr.data[b] = outputs_conv_27_conv;
16650         }
16651         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16652         *ret_copy = Event_spendable_outputs(outputs_constr);
16653         uint64_t ret_ref = (uint64_t)ret_copy;
16654         return ret_ref;
16655 }
16656
16657 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
16658         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
16659         CHECK_ACCESS(fee_earned_msat_ptr);
16660         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16661         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
16662         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16663         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16664         uint64_t ret_ref = (uint64_t)ret_copy;
16665         return ret_ref;
16666 }
16667
16668 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) {
16669         LDKThirtyTwoBytes channel_id_ref;
16670         CHECK(channel_id->arr_len == 32);
16671         memcpy(channel_id_ref.data, channel_id->elems, 32);
16672         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
16673         CHECK_ACCESS(reason_ptr);
16674         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16675         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
16676         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16677         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16678         uint64_t ret_ref = (uint64_t)ret_copy;
16679         return ret_ref;
16680 }
16681
16682 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
16683         LDKThirtyTwoBytes channel_id_ref;
16684         CHECK(channel_id->arr_len == 32);
16685         memcpy(channel_id_ref.data, channel_id->elems, 32);
16686         LDKTransaction transaction_ref;
16687         transaction_ref.datalen = transaction->arr_len;
16688         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16689         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen);
16690         transaction_ref.data_is_owned = true;
16691         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16692         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16693         uint64_t ret_ref = (uint64_t)ret_copy;
16694         return ret_ref;
16695 }
16696
16697 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) {
16698         LDKThirtyTwoBytes payment_id_ref;
16699         CHECK(payment_id->arr_len == 32);
16700         memcpy(payment_id_ref.data, payment_id->elems, 32);
16701         LDKThirtyTwoBytes payment_hash_ref;
16702         CHECK(payment_hash->arr_len == 32);
16703         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
16704         LDKCVec_RouteHopZ path_constr;
16705         path_constr.datalen = path->arr_len;
16706         if (path_constr.datalen > 0)
16707                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16708         else
16709                 path_constr.data = NULL;
16710         uint32_t* path_vals = path->elems;
16711         for (size_t k = 0; k < path_constr.datalen; k++) {
16712                 uint32_t path_conv_10 = path_vals[k];
16713                 LDKRouteHop path_conv_10_conv;
16714                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16715                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16716                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16717                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16718                 path_constr.data[k] = path_conv_10_conv;
16719         }
16720         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16721         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
16722         uint64_t ret_ref = (uint64_t)ret_copy;
16723         return ret_ref;
16724 }
16725
16726 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
16727         LDKEvent* obj_conv = (LDKEvent*)obj;
16728         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16729         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
16730         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16731         CVec_u8Z_free(ret_var);
16732         return ret_arr;
16733 }
16734
16735 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
16736         LDKu8slice ser_ref;
16737         ser_ref.datalen = ser->arr_len;
16738         ser_ref.data = ser->elems;
16739         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16740         *ret_conv = Event_read(ser_ref);
16741         return (uint64_t)ret_conv;
16742 }
16743
16744 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
16745         if ((this_ptr & 1) != 0) return;
16746         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16747         CHECK_ACCESS(this_ptr_ptr);
16748         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16749         FREE((void*)this_ptr);
16750         MessageSendEvent_free(this_ptr_conv);
16751 }
16752
16753 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
16754         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16755         *ret_copy = MessageSendEvent_clone(arg);
16756 uint64_t ret_ref = (uint64_t)ret_copy;
16757         return ret_ref;
16758 }
16759 int64_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
16760         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
16761         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
16762         return ret_val;
16763 }
16764
16765 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
16766         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16767         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16768         *ret_copy = MessageSendEvent_clone(orig_conv);
16769         uint64_t ret_ref = (uint64_t)ret_copy;
16770         return ret_ref;
16771 }
16772
16773 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
16774         LDKPublicKey node_id_ref;
16775         CHECK(node_id->arr_len == 33);
16776         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16777         LDKAcceptChannel msg_conv;
16778         msg_conv.inner = (void*)(msg & (~1));
16779         msg_conv.is_owned = (msg & 1) || (msg == 0);
16780         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16781         msg_conv = AcceptChannel_clone(&msg_conv);
16782         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16783         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16784         uint64_t ret_ref = (uint64_t)ret_copy;
16785         return ret_ref;
16786 }
16787
16788 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
16789         LDKPublicKey node_id_ref;
16790         CHECK(node_id->arr_len == 33);
16791         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16792         LDKOpenChannel msg_conv;
16793         msg_conv.inner = (void*)(msg & (~1));
16794         msg_conv.is_owned = (msg & 1) || (msg == 0);
16795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16796         msg_conv = OpenChannel_clone(&msg_conv);
16797         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16798         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16799         uint64_t ret_ref = (uint64_t)ret_copy;
16800         return ret_ref;
16801 }
16802
16803 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
16804         LDKPublicKey node_id_ref;
16805         CHECK(node_id->arr_len == 33);
16806         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16807         LDKFundingCreated msg_conv;
16808         msg_conv.inner = (void*)(msg & (~1));
16809         msg_conv.is_owned = (msg & 1) || (msg == 0);
16810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16811         msg_conv = FundingCreated_clone(&msg_conv);
16812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16813         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16814         uint64_t ret_ref = (uint64_t)ret_copy;
16815         return ret_ref;
16816 }
16817
16818 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
16819         LDKPublicKey node_id_ref;
16820         CHECK(node_id->arr_len == 33);
16821         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16822         LDKFundingSigned msg_conv;
16823         msg_conv.inner = (void*)(msg & (~1));
16824         msg_conv.is_owned = (msg & 1) || (msg == 0);
16825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16826         msg_conv = FundingSigned_clone(&msg_conv);
16827         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16828         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16829         uint64_t ret_ref = (uint64_t)ret_copy;
16830         return ret_ref;
16831 }
16832
16833 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
16834         LDKPublicKey node_id_ref;
16835         CHECK(node_id->arr_len == 33);
16836         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16837         LDKFundingLocked msg_conv;
16838         msg_conv.inner = (void*)(msg & (~1));
16839         msg_conv.is_owned = (msg & 1) || (msg == 0);
16840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16841         msg_conv = FundingLocked_clone(&msg_conv);
16842         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16843         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16844         uint64_t ret_ref = (uint64_t)ret_copy;
16845         return ret_ref;
16846 }
16847
16848 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
16849         LDKPublicKey node_id_ref;
16850         CHECK(node_id->arr_len == 33);
16851         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16852         LDKAnnouncementSignatures msg_conv;
16853         msg_conv.inner = (void*)(msg & (~1));
16854         msg_conv.is_owned = (msg & 1) || (msg == 0);
16855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16856         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16857         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16858         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16859         uint64_t ret_ref = (uint64_t)ret_copy;
16860         return ret_ref;
16861 }
16862
16863 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
16864         LDKPublicKey node_id_ref;
16865         CHECK(node_id->arr_len == 33);
16866         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16867         LDKCommitmentUpdate updates_conv;
16868         updates_conv.inner = (void*)(updates & (~1));
16869         updates_conv.is_owned = (updates & 1) || (updates == 0);
16870         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
16871         updates_conv = CommitmentUpdate_clone(&updates_conv);
16872         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16873         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
16874         uint64_t ret_ref = (uint64_t)ret_copy;
16875         return ret_ref;
16876 }
16877
16878 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
16879         LDKPublicKey node_id_ref;
16880         CHECK(node_id->arr_len == 33);
16881         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16882         LDKRevokeAndACK msg_conv;
16883         msg_conv.inner = (void*)(msg & (~1));
16884         msg_conv.is_owned = (msg & 1) || (msg == 0);
16885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16886         msg_conv = RevokeAndACK_clone(&msg_conv);
16887         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16888         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
16889         uint64_t ret_ref = (uint64_t)ret_copy;
16890         return ret_ref;
16891 }
16892
16893 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
16894         LDKPublicKey node_id_ref;
16895         CHECK(node_id->arr_len == 33);
16896         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16897         LDKClosingSigned msg_conv;
16898         msg_conv.inner = (void*)(msg & (~1));
16899         msg_conv.is_owned = (msg & 1) || (msg == 0);
16900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16901         msg_conv = ClosingSigned_clone(&msg_conv);
16902         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16903         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
16904         uint64_t ret_ref = (uint64_t)ret_copy;
16905         return ret_ref;
16906 }
16907
16908 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
16909         LDKPublicKey node_id_ref;
16910         CHECK(node_id->arr_len == 33);
16911         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16912         LDKShutdown msg_conv;
16913         msg_conv.inner = (void*)(msg & (~1));
16914         msg_conv.is_owned = (msg & 1) || (msg == 0);
16915         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16916         msg_conv = Shutdown_clone(&msg_conv);
16917         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16918         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
16919         uint64_t ret_ref = (uint64_t)ret_copy;
16920         return ret_ref;
16921 }
16922
16923 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
16924         LDKPublicKey node_id_ref;
16925         CHECK(node_id->arr_len == 33);
16926         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16927         LDKChannelReestablish msg_conv;
16928         msg_conv.inner = (void*)(msg & (~1));
16929         msg_conv.is_owned = (msg & 1) || (msg == 0);
16930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16931         msg_conv = ChannelReestablish_clone(&msg_conv);
16932         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16933         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
16934         uint64_t ret_ref = (uint64_t)ret_copy;
16935         return ret_ref;
16936 }
16937
16938 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
16939         LDKChannelAnnouncement msg_conv;
16940         msg_conv.inner = (void*)(msg & (~1));
16941         msg_conv.is_owned = (msg & 1) || (msg == 0);
16942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16943         msg_conv = ChannelAnnouncement_clone(&msg_conv);
16944         LDKChannelUpdate update_msg_conv;
16945         update_msg_conv.inner = (void*)(update_msg & (~1));
16946         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
16947         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
16948         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
16949         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16950         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
16951         uint64_t ret_ref = (uint64_t)ret_copy;
16952         return ret_ref;
16953 }
16954
16955 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
16956         LDKNodeAnnouncement msg_conv;
16957         msg_conv.inner = (void*)(msg & (~1));
16958         msg_conv.is_owned = (msg & 1) || (msg == 0);
16959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16960         msg_conv = NodeAnnouncement_clone(&msg_conv);
16961         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16962         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
16963         uint64_t ret_ref = (uint64_t)ret_copy;
16964         return ret_ref;
16965 }
16966
16967 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
16968         LDKChannelUpdate msg_conv;
16969         msg_conv.inner = (void*)(msg & (~1));
16970         msg_conv.is_owned = (msg & 1) || (msg == 0);
16971         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16972         msg_conv = ChannelUpdate_clone(&msg_conv);
16973         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16974         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
16975         uint64_t ret_ref = (uint64_t)ret_copy;
16976         return ret_ref;
16977 }
16978
16979 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
16980         LDKPublicKey node_id_ref;
16981         CHECK(node_id->arr_len == 33);
16982         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16983         LDKChannelUpdate msg_conv;
16984         msg_conv.inner = (void*)(msg & (~1));
16985         msg_conv.is_owned = (msg & 1) || (msg == 0);
16986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16987         msg_conv = ChannelUpdate_clone(&msg_conv);
16988         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16989         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
16990         uint64_t ret_ref = (uint64_t)ret_copy;
16991         return ret_ref;
16992 }
16993
16994 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
16995         LDKPublicKey node_id_ref;
16996         CHECK(node_id->arr_len == 33);
16997         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
16998         void* action_ptr = (void*)(((uint64_t)action) & ~1);
16999         CHECK_ACCESS(action_ptr);
17000         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
17001         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
17002         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17003         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
17004         uint64_t ret_ref = (uint64_t)ret_copy;
17005         return ret_ref;
17006 }
17007
17008 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
17009         LDKPublicKey node_id_ref;
17010         CHECK(node_id->arr_len == 33);
17011         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
17012         LDKQueryChannelRange msg_conv;
17013         msg_conv.inner = (void*)(msg & (~1));
17014         msg_conv.is_owned = (msg & 1) || (msg == 0);
17015         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17016         msg_conv = QueryChannelRange_clone(&msg_conv);
17017         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17018         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
17019         uint64_t ret_ref = (uint64_t)ret_copy;
17020         return ret_ref;
17021 }
17022
17023 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
17024         LDKPublicKey node_id_ref;
17025         CHECK(node_id->arr_len == 33);
17026         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
17027         LDKQueryShortChannelIds msg_conv;
17028         msg_conv.inner = (void*)(msg & (~1));
17029         msg_conv.is_owned = (msg & 1) || (msg == 0);
17030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17031         msg_conv = QueryShortChannelIds_clone(&msg_conv);
17032         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17033         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
17034         uint64_t ret_ref = (uint64_t)ret_copy;
17035         return ret_ref;
17036 }
17037
17038 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
17039         LDKPublicKey node_id_ref;
17040         CHECK(node_id->arr_len == 33);
17041         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
17042         LDKReplyChannelRange msg_conv;
17043         msg_conv.inner = (void*)(msg & (~1));
17044         msg_conv.is_owned = (msg & 1) || (msg == 0);
17045         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17046         msg_conv = ReplyChannelRange_clone(&msg_conv);
17047         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17048         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
17049         uint64_t ret_ref = (uint64_t)ret_copy;
17050         return ret_ref;
17051 }
17052
17053 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
17054         if ((this_ptr & 1) != 0) return;
17055         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17056         CHECK_ACCESS(this_ptr_ptr);
17057         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
17058         FREE((void*)this_ptr);
17059         MessageSendEventsProvider_free(this_ptr_conv);
17060 }
17061
17062 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
17063         if ((this_ptr & 1) != 0) return;
17064         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17065         CHECK_ACCESS(this_ptr_ptr);
17066         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
17067         FREE((void*)this_ptr);
17068         EventsProvider_free(this_ptr_conv);
17069 }
17070
17071 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
17072         if ((this_ptr & 1) != 0) return;
17073         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17074         CHECK_ACCESS(this_ptr_ptr);
17075         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
17076         FREE((void*)this_ptr);
17077         EventHandler_free(this_ptr_conv);
17078 }
17079
17080 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
17081         if ((this_ptr & 1) != 0) return;
17082         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17083         CHECK_ACCESS(this_ptr_ptr);
17084         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
17085         FREE((void*)this_ptr);
17086         APIError_free(this_ptr_conv);
17087 }
17088
17089 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
17090         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17091         *ret_copy = APIError_clone(arg);
17092 uint64_t ret_ref = (uint64_t)ret_copy;
17093         return ret_ref;
17094 }
17095 int64_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
17096         LDKAPIError* arg_conv = (LDKAPIError*)arg;
17097         int64_t ret_val = APIError_clone_ptr(arg_conv);
17098         return ret_val;
17099 }
17100
17101 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
17102         LDKAPIError* orig_conv = (LDKAPIError*)orig;
17103         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17104         *ret_copy = APIError_clone(orig_conv);
17105         uint64_t ret_ref = (uint64_t)ret_copy;
17106         return ret_ref;
17107 }
17108
17109 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
17110         LDKStr err_conv = str_ref_to_owned_c(err);
17111         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17112         *ret_copy = APIError_apimisuse_error(err_conv);
17113         uint64_t ret_ref = (uint64_t)ret_copy;
17114         return ret_ref;
17115 }
17116
17117 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
17118         LDKStr err_conv = str_ref_to_owned_c(err);
17119         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17120         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
17121         uint64_t ret_ref = (uint64_t)ret_copy;
17122         return ret_ref;
17123 }
17124
17125 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
17126         LDKStr err_conv = str_ref_to_owned_c(err);
17127         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17128         *ret_copy = APIError_route_error(err_conv);
17129         uint64_t ret_ref = (uint64_t)ret_copy;
17130         return ret_ref;
17131 }
17132
17133 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
17134         LDKStr err_conv = str_ref_to_owned_c(err);
17135         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17136         *ret_copy = APIError_channel_unavailable(err_conv);
17137         uint64_t ret_ref = (uint64_t)ret_copy;
17138         return ret_ref;
17139 }
17140
17141 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
17142         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17143         *ret_copy = APIError_monitor_update_failed();
17144         uint64_t ret_ref = (uint64_t)ret_copy;
17145         return ret_ref;
17146 }
17147
17148 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
17149         LDKShutdownScript script_conv;
17150         script_conv.inner = (void*)(script & (~1));
17151         script_conv.is_owned = (script & 1) || (script == 0);
17152         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
17153         script_conv = ShutdownScript_clone(&script_conv);
17154         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17155         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
17156         uint64_t ret_ref = (uint64_t)ret_copy;
17157         return ret_ref;
17158 }
17159
17160 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
17161         LDKu8slice msg_ref;
17162         msg_ref.datalen = msg->arr_len;
17163         msg_ref.data = msg->elems;
17164         unsigned char sk_arr[32];
17165         CHECK(sk->arr_len == 32);
17166         memcpy(sk_arr, sk->elems, 32);
17167         unsigned char (*sk_ref)[32] = &sk_arr;
17168         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17169         *ret_conv = sign(msg_ref, sk_ref);
17170         return (uint64_t)ret_conv;
17171 }
17172
17173 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
17174         LDKu8slice msg_ref;
17175         msg_ref.datalen = msg->arr_len;
17176         msg_ref.data = msg->elems;
17177         LDKStr sig_conv = str_ref_to_owned_c(sig);
17178         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17179         *ret_conv = recover_pk(msg_ref, sig_conv);
17180         return (uint64_t)ret_conv;
17181 }
17182
17183 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
17184         LDKu8slice msg_ref;
17185         msg_ref.datalen = msg->arr_len;
17186         msg_ref.data = msg->elems;
17187         LDKStr sig_conv = str_ref_to_owned_c(sig);
17188         LDKPublicKey pk_ref;
17189         CHECK(pk->arr_len == 33);
17190         memcpy(pk_ref.compressed_form, pk->elems, 33);
17191         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
17192         return ret_val;
17193 }
17194
17195 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
17196         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
17197         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
17198         return ret_conv;
17199 }
17200
17201 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
17202         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
17203         return ret_conv;
17204 }
17205
17206 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
17207         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
17208         return ret_conv;
17209 }
17210
17211 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
17212         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
17213         return ret_conv;
17214 }
17215
17216 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
17217         uint32_t ret_conv = LDKLevel_to_js(Level_info());
17218         return ret_conv;
17219 }
17220
17221 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
17222         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
17223         return ret_conv;
17224 }
17225
17226 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
17227         uint32_t ret_conv = LDKLevel_to_js(Level_error());
17228         return ret_conv;
17229 }
17230
17231 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
17232         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
17233         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
17234         jboolean ret_val = Level_eq(a_conv, b_conv);
17235         return ret_val;
17236 }
17237
17238 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
17239         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
17240         int64_t ret_val = Level_hash(o_conv);
17241         return ret_val;
17242 }
17243
17244 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
17245         uint32_t ret_conv = LDKLevel_to_js(Level_max());
17246         return ret_conv;
17247 }
17248
17249 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
17250         LDKRecord this_obj_conv;
17251         this_obj_conv.inner = (void*)(this_obj & (~1));
17252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17254         Record_free(this_obj_conv);
17255 }
17256
17257 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
17258         LDKRecord this_ptr_conv;
17259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17260         this_ptr_conv.is_owned = false;
17261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17262         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
17263         return ret_conv;
17264 }
17265
17266 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
17267         LDKRecord this_ptr_conv;
17268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17269         this_ptr_conv.is_owned = false;
17270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17271         LDKLevel val_conv = LDKLevel_from_js(val);
17272         Record_set_level(&this_ptr_conv, val_conv);
17273 }
17274
17275 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
17276         LDKRecord this_ptr_conv;
17277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17278         this_ptr_conv.is_owned = false;
17279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17280         LDKStr ret_str = Record_get_args(&this_ptr_conv);
17281         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17282         Str_free(ret_str);
17283         return ret_conv;
17284 }
17285
17286 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
17287         LDKRecord this_ptr_conv;
17288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17289         this_ptr_conv.is_owned = false;
17290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17291         LDKStr val_conv = str_ref_to_owned_c(val);
17292         Record_set_args(&this_ptr_conv, val_conv);
17293 }
17294
17295 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
17296         LDKRecord this_ptr_conv;
17297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17298         this_ptr_conv.is_owned = false;
17299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17300         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
17301         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17302         Str_free(ret_str);
17303         return ret_conv;
17304 }
17305
17306 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
17307         LDKRecord this_ptr_conv;
17308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17309         this_ptr_conv.is_owned = false;
17310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17311         LDKStr val_conv = str_ref_to_owned_c(val);
17312         Record_set_module_path(&this_ptr_conv, val_conv);
17313 }
17314
17315 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
17316         LDKRecord this_ptr_conv;
17317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17318         this_ptr_conv.is_owned = false;
17319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17320         LDKStr ret_str = Record_get_file(&this_ptr_conv);
17321         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17322         Str_free(ret_str);
17323         return ret_conv;
17324 }
17325
17326 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
17327         LDKRecord this_ptr_conv;
17328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17329         this_ptr_conv.is_owned = false;
17330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17331         LDKStr val_conv = str_ref_to_owned_c(val);
17332         Record_set_file(&this_ptr_conv, val_conv);
17333 }
17334
17335 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
17336         LDKRecord this_ptr_conv;
17337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17338         this_ptr_conv.is_owned = false;
17339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17340         int32_t ret_val = Record_get_line(&this_ptr_conv);
17341         return ret_val;
17342 }
17343
17344 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
17345         LDKRecord this_ptr_conv;
17346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17347         this_ptr_conv.is_owned = false;
17348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17349         Record_set_line(&this_ptr_conv, val);
17350 }
17351
17352 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
17353         LDKRecord ret_var = Record_clone(arg);
17354 uint64_t ret_ref = 0;
17355 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17356 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17357 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17358 ret_ref = (uint64_t)ret_var.inner;
17359 if (ret_var.is_owned) {
17360         ret_ref |= 1;
17361 }
17362         return ret_ref;
17363 }
17364 int64_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
17365         LDKRecord arg_conv;
17366         arg_conv.inner = (void*)(arg & (~1));
17367         arg_conv.is_owned = false;
17368         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17369         int64_t ret_val = Record_clone_ptr(&arg_conv);
17370         return ret_val;
17371 }
17372
17373 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
17374         LDKRecord orig_conv;
17375         orig_conv.inner = (void*)(orig & (~1));
17376         orig_conv.is_owned = false;
17377         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17378         LDKRecord ret_var = Record_clone(&orig_conv);
17379         uint64_t ret_ref = 0;
17380         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17381         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17383         ret_ref = (uint64_t)ret_var.inner;
17384         if (ret_var.is_owned) {
17385                 ret_ref |= 1;
17386         }
17387         return ret_ref;
17388 }
17389
17390 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
17391         if ((this_ptr & 1) != 0) return;
17392         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17393         CHECK_ACCESS(this_ptr_ptr);
17394         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
17395         FREE((void*)this_ptr);
17396         Logger_free(this_ptr_conv);
17397 }
17398
17399 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
17400         LDKChannelHandshakeConfig this_obj_conv;
17401         this_obj_conv.inner = (void*)(this_obj & (~1));
17402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17404         ChannelHandshakeConfig_free(this_obj_conv);
17405 }
17406
17407 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
17408         LDKChannelHandshakeConfig this_ptr_conv;
17409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17410         this_ptr_conv.is_owned = false;
17411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17412         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
17413         return ret_val;
17414 }
17415
17416 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
17417         LDKChannelHandshakeConfig this_ptr_conv;
17418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17419         this_ptr_conv.is_owned = false;
17420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17421         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
17422 }
17423
17424 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
17425         LDKChannelHandshakeConfig this_ptr_conv;
17426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17427         this_ptr_conv.is_owned = false;
17428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17429         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17430         return ret_val;
17431 }
17432
17433 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) {
17434         LDKChannelHandshakeConfig this_ptr_conv;
17435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17436         this_ptr_conv.is_owned = false;
17437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17438         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17439 }
17440
17441 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
17442         LDKChannelHandshakeConfig this_ptr_conv;
17443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17444         this_ptr_conv.is_owned = false;
17445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17446         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17447         return ret_val;
17448 }
17449
17450 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) {
17451         LDKChannelHandshakeConfig this_ptr_conv;
17452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17453         this_ptr_conv.is_owned = false;
17454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17455         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17456 }
17457
17458 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) {
17459         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17460         uint64_t ret_ref = 0;
17461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17464         ret_ref = (uint64_t)ret_var.inner;
17465         if (ret_var.is_owned) {
17466                 ret_ref |= 1;
17467         }
17468         return ret_ref;
17469 }
17470
17471 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
17472         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
17473 uint64_t ret_ref = 0;
17474 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17475 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17478 if (ret_var.is_owned) {
17479         ret_ref |= 1;
17480 }
17481         return ret_ref;
17482 }
17483 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
17484         LDKChannelHandshakeConfig arg_conv;
17485         arg_conv.inner = (void*)(arg & (~1));
17486         arg_conv.is_owned = false;
17487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17488         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
17489         return ret_val;
17490 }
17491
17492 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
17493         LDKChannelHandshakeConfig orig_conv;
17494         orig_conv.inner = (void*)(orig & (~1));
17495         orig_conv.is_owned = false;
17496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17497         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17498         uint64_t ret_ref = 0;
17499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17502         ret_ref = (uint64_t)ret_var.inner;
17503         if (ret_var.is_owned) {
17504                 ret_ref |= 1;
17505         }
17506         return ret_ref;
17507 }
17508
17509 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
17510         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17511         uint64_t ret_ref = 0;
17512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17513         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17516         if (ret_var.is_owned) {
17517                 ret_ref |= 1;
17518         }
17519         return ret_ref;
17520 }
17521
17522 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
17523         LDKChannelHandshakeLimits this_obj_conv;
17524         this_obj_conv.inner = (void*)(this_obj & (~1));
17525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17527         ChannelHandshakeLimits_free(this_obj_conv);
17528 }
17529
17530 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
17531         LDKChannelHandshakeLimits this_ptr_conv;
17532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17533         this_ptr_conv.is_owned = false;
17534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17535         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17536         return ret_val;
17537 }
17538
17539 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
17540         LDKChannelHandshakeLimits this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17544         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17545 }
17546
17547 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
17548         LDKChannelHandshakeLimits this_ptr_conv;
17549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17550         this_ptr_conv.is_owned = false;
17551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17552         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17553         return ret_val;
17554 }
17555
17556 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) {
17557         LDKChannelHandshakeLimits this_ptr_conv;
17558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17559         this_ptr_conv.is_owned = false;
17560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17561         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17562 }
17563
17564 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) {
17565         LDKChannelHandshakeLimits this_ptr_conv;
17566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17567         this_ptr_conv.is_owned = false;
17568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17569         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17570         return ret_val;
17571 }
17572
17573 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) {
17574         LDKChannelHandshakeLimits this_ptr_conv;
17575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17576         this_ptr_conv.is_owned = false;
17577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17578         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17579 }
17580
17581 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
17582         LDKChannelHandshakeLimits this_ptr_conv;
17583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17584         this_ptr_conv.is_owned = false;
17585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17586         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17587         return ret_val;
17588 }
17589
17590 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) {
17591         LDKChannelHandshakeLimits this_ptr_conv;
17592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17593         this_ptr_conv.is_owned = false;
17594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17595         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17596 }
17597
17598 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
17599         LDKChannelHandshakeLimits this_ptr_conv;
17600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17601         this_ptr_conv.is_owned = false;
17602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17603         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17604         return ret_val;
17605 }
17606
17607 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) {
17608         LDKChannelHandshakeLimits this_ptr_conv;
17609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17610         this_ptr_conv.is_owned = false;
17611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17612         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17613 }
17614
17615 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
17616         LDKChannelHandshakeLimits this_ptr_conv;
17617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17618         this_ptr_conv.is_owned = false;
17619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17620         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17621         return ret_val;
17622 }
17623
17624 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
17625         LDKChannelHandshakeLimits this_ptr_conv;
17626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17627         this_ptr_conv.is_owned = false;
17628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17629         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17630 }
17631
17632 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
17633         LDKChannelHandshakeLimits this_ptr_conv;
17634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17635         this_ptr_conv.is_owned = false;
17636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17637         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17638         return ret_val;
17639 }
17640
17641 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
17642         LDKChannelHandshakeLimits this_ptr_conv;
17643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17644         this_ptr_conv.is_owned = false;
17645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17646         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17647 }
17648
17649 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
17650         LDKChannelHandshakeLimits this_ptr_conv;
17651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17652         this_ptr_conv.is_owned = false;
17653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17654         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17655         return ret_val;
17656 }
17657
17658 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) {
17659         LDKChannelHandshakeLimits this_ptr_conv;
17660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17661         this_ptr_conv.is_owned = false;
17662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17663         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17664 }
17665
17666 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) {
17667         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);
17668         uint64_t ret_ref = 0;
17669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17672         ret_ref = (uint64_t)ret_var.inner;
17673         if (ret_var.is_owned) {
17674                 ret_ref |= 1;
17675         }
17676         return ret_ref;
17677 }
17678
17679 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
17680         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
17681 uint64_t ret_ref = 0;
17682 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17683 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17686 if (ret_var.is_owned) {
17687         ret_ref |= 1;
17688 }
17689         return ret_ref;
17690 }
17691 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
17692         LDKChannelHandshakeLimits arg_conv;
17693         arg_conv.inner = (void*)(arg & (~1));
17694         arg_conv.is_owned = false;
17695         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17696         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
17697         return ret_val;
17698 }
17699
17700 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
17701         LDKChannelHandshakeLimits orig_conv;
17702         orig_conv.inner = (void*)(orig & (~1));
17703         orig_conv.is_owned = false;
17704         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17705         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
17706         uint64_t ret_ref = 0;
17707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17710         ret_ref = (uint64_t)ret_var.inner;
17711         if (ret_var.is_owned) {
17712                 ret_ref |= 1;
17713         }
17714         return ret_ref;
17715 }
17716
17717 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
17718         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
17719         uint64_t ret_ref = 0;
17720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17721         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17724         if (ret_var.is_owned) {
17725                 ret_ref |= 1;
17726         }
17727         return ret_ref;
17728 }
17729
17730 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
17731         LDKChannelConfig this_obj_conv;
17732         this_obj_conv.inner = (void*)(this_obj & (~1));
17733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17735         ChannelConfig_free(this_obj_conv);
17736 }
17737
17738 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
17739         LDKChannelConfig this_ptr_conv;
17740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17741         this_ptr_conv.is_owned = false;
17742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17743         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
17744         return ret_val;
17745 }
17746
17747 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) {
17748         LDKChannelConfig this_ptr_conv;
17749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17750         this_ptr_conv.is_owned = false;
17751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17752         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
17753 }
17754
17755 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
17756         LDKChannelConfig this_ptr_conv;
17757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17758         this_ptr_conv.is_owned = false;
17759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17760         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
17761         return ret_val;
17762 }
17763
17764 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) {
17765         LDKChannelConfig this_ptr_conv;
17766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17767         this_ptr_conv.is_owned = false;
17768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17769         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
17770 }
17771
17772 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
17773         LDKChannelConfig this_ptr_conv;
17774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17775         this_ptr_conv.is_owned = false;
17776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17777         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
17778         return ret_val;
17779 }
17780
17781 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17782         LDKChannelConfig this_ptr_conv;
17783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17784         this_ptr_conv.is_owned = false;
17785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17786         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
17787 }
17788
17789 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
17790         LDKChannelConfig this_ptr_conv;
17791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17792         this_ptr_conv.is_owned = false;
17793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17794         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
17795         return ret_val;
17796 }
17797
17798 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
17799         LDKChannelConfig this_ptr_conv;
17800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17801         this_ptr_conv.is_owned = false;
17802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17803         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
17804 }
17805
17806 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
17807         LDKChannelConfig this_ptr_conv;
17808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17809         this_ptr_conv.is_owned = false;
17810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17811         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
17812         return ret_val;
17813 }
17814
17815 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
17816         LDKChannelConfig this_ptr_conv;
17817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17818         this_ptr_conv.is_owned = false;
17819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17820         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
17821 }
17822
17823 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) {
17824         LDKChannelConfig this_ptr_conv;
17825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17826         this_ptr_conv.is_owned = false;
17827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17828         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
17829         return ret_val;
17830 }
17831
17832 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) {
17833         LDKChannelConfig this_ptr_conv;
17834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17835         this_ptr_conv.is_owned = false;
17836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17837         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
17838 }
17839
17840 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) {
17841         LDKChannelConfig this_ptr_conv;
17842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17843         this_ptr_conv.is_owned = false;
17844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17845         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
17846         return ret_val;
17847 }
17848
17849 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) {
17850         LDKChannelConfig this_ptr_conv;
17851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17852         this_ptr_conv.is_owned = false;
17853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17854         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
17855 }
17856
17857 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) {
17858         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);
17859         uint64_t ret_ref = 0;
17860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17863         ret_ref = (uint64_t)ret_var.inner;
17864         if (ret_var.is_owned) {
17865                 ret_ref |= 1;
17866         }
17867         return ret_ref;
17868 }
17869
17870 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
17871         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
17872 uint64_t ret_ref = 0;
17873 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17874 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17877 if (ret_var.is_owned) {
17878         ret_ref |= 1;
17879 }
17880         return ret_ref;
17881 }
17882 int64_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
17883         LDKChannelConfig arg_conv;
17884         arg_conv.inner = (void*)(arg & (~1));
17885         arg_conv.is_owned = false;
17886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17887         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
17888         return ret_val;
17889 }
17890
17891 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
17892         LDKChannelConfig orig_conv;
17893         orig_conv.inner = (void*)(orig & (~1));
17894         orig_conv.is_owned = false;
17895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17896         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
17897         uint64_t ret_ref = 0;
17898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17901         ret_ref = (uint64_t)ret_var.inner;
17902         if (ret_var.is_owned) {
17903                 ret_ref |= 1;
17904         }
17905         return ret_ref;
17906 }
17907
17908 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
17909         LDKChannelConfig ret_var = ChannelConfig_default();
17910         uint64_t ret_ref = 0;
17911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17912         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
17915         if (ret_var.is_owned) {
17916                 ret_ref |= 1;
17917         }
17918         return ret_ref;
17919 }
17920
17921 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
17922         LDKChannelConfig obj_conv;
17923         obj_conv.inner = (void*)(obj & (~1));
17924         obj_conv.is_owned = false;
17925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
17926         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
17927         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
17928         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
17929         CVec_u8Z_free(ret_var);
17930         return ret_arr;
17931 }
17932
17933 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
17934         LDKu8slice ser_ref;
17935         ser_ref.datalen = ser->arr_len;
17936         ser_ref.data = ser->elems;
17937         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
17938         *ret_conv = ChannelConfig_read(ser_ref);
17939         return (uint64_t)ret_conv;
17940 }
17941
17942 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
17943         LDKUserConfig this_obj_conv;
17944         this_obj_conv.inner = (void*)(this_obj & (~1));
17945         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17947         UserConfig_free(this_obj_conv);
17948 }
17949
17950 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
17951         LDKUserConfig this_ptr_conv;
17952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17953         this_ptr_conv.is_owned = false;
17954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17955         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
17956         uint64_t ret_ref = 0;
17957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17960         ret_ref = (uint64_t)ret_var.inner;
17961         if (ret_var.is_owned) {
17962                 ret_ref |= 1;
17963         }
17964         return ret_ref;
17965 }
17966
17967 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
17968         LDKUserConfig this_ptr_conv;
17969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17970         this_ptr_conv.is_owned = false;
17971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17972         LDKChannelHandshakeConfig val_conv;
17973         val_conv.inner = (void*)(val & (~1));
17974         val_conv.is_owned = (val & 1) || (val == 0);
17975         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17976         val_conv = ChannelHandshakeConfig_clone(&val_conv);
17977         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
17978 }
17979
17980 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
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         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
17986         uint64_t ret_ref = 0;
17987         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17988         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17990         ret_ref = (uint64_t)ret_var.inner;
17991         if (ret_var.is_owned) {
17992                 ret_ref |= 1;
17993         }
17994         return ret_ref;
17995 }
17996
17997 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) {
17998         LDKUserConfig this_ptr_conv;
17999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18000         this_ptr_conv.is_owned = false;
18001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18002         LDKChannelHandshakeLimits val_conv;
18003         val_conv.inner = (void*)(val & (~1));
18004         val_conv.is_owned = (val & 1) || (val == 0);
18005         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18006         val_conv = ChannelHandshakeLimits_clone(&val_conv);
18007         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
18008 }
18009
18010 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
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         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
18016         uint64_t ret_ref = 0;
18017         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18018         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18020         ret_ref = (uint64_t)ret_var.inner;
18021         if (ret_var.is_owned) {
18022                 ret_ref |= 1;
18023         }
18024         return ret_ref;
18025 }
18026
18027 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
18028         LDKUserConfig this_ptr_conv;
18029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18030         this_ptr_conv.is_owned = false;
18031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18032         LDKChannelConfig val_conv;
18033         val_conv.inner = (void*)(val & (~1));
18034         val_conv.is_owned = (val & 1) || (val == 0);
18035         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18036         val_conv = ChannelConfig_clone(&val_conv);
18037         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
18038 }
18039
18040 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
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         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
18046         return ret_val;
18047 }
18048
18049 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) {
18050         LDKUserConfig this_ptr_conv;
18051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18052         this_ptr_conv.is_owned = false;
18053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18054         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
18055 }
18056
18057 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
18058         LDKUserConfig this_ptr_conv;
18059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18060         this_ptr_conv.is_owned = false;
18061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18062         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
18063         return ret_val;
18064 }
18065
18066 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
18067         LDKUserConfig this_ptr_conv;
18068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18069         this_ptr_conv.is_owned = false;
18070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18071         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
18072 }
18073
18074 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) {
18075         LDKChannelHandshakeConfig own_channel_config_arg_conv;
18076         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
18077         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
18078         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
18079         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
18080         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
18081         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
18082         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
18083         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
18084         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
18085         LDKChannelConfig channel_options_arg_conv;
18086         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
18087         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
18088         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
18089         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
18090         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);
18091         uint64_t ret_ref = 0;
18092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18095         ret_ref = (uint64_t)ret_var.inner;
18096         if (ret_var.is_owned) {
18097                 ret_ref |= 1;
18098         }
18099         return ret_ref;
18100 }
18101
18102 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
18103         LDKUserConfig ret_var = UserConfig_clone(arg);
18104 uint64_t ret_ref = 0;
18105 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18106 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
18109 if (ret_var.is_owned) {
18110         ret_ref |= 1;
18111 }
18112         return ret_ref;
18113 }
18114 int64_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
18115         LDKUserConfig arg_conv;
18116         arg_conv.inner = (void*)(arg & (~1));
18117         arg_conv.is_owned = false;
18118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18119         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
18120         return ret_val;
18121 }
18122
18123 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
18124         LDKUserConfig orig_conv;
18125         orig_conv.inner = (void*)(orig & (~1));
18126         orig_conv.is_owned = false;
18127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18128         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
18129         uint64_t ret_ref = 0;
18130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18133         ret_ref = (uint64_t)ret_var.inner;
18134         if (ret_var.is_owned) {
18135                 ret_ref |= 1;
18136         }
18137         return ret_ref;
18138 }
18139
18140 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
18141         LDKUserConfig ret_var = UserConfig_default();
18142         uint64_t ret_ref = 0;
18143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18144         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
18147         if (ret_var.is_owned) {
18148                 ret_ref |= 1;
18149         }
18150         return ret_ref;
18151 }
18152
18153 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
18154         LDKBestBlock this_obj_conv;
18155         this_obj_conv.inner = (void*)(this_obj & (~1));
18156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18158         BestBlock_free(this_obj_conv);
18159 }
18160
18161 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
18162         LDKBestBlock ret_var = BestBlock_clone(arg);
18163 uint64_t ret_ref = 0;
18164 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18165 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18166 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18167 ret_ref = (uint64_t)ret_var.inner;
18168 if (ret_var.is_owned) {
18169         ret_ref |= 1;
18170 }
18171         return ret_ref;
18172 }
18173 int64_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
18174         LDKBestBlock arg_conv;
18175         arg_conv.inner = (void*)(arg & (~1));
18176         arg_conv.is_owned = false;
18177         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18178         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
18179         return ret_val;
18180 }
18181
18182 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
18183         LDKBestBlock orig_conv;
18184         orig_conv.inner = (void*)(orig & (~1));
18185         orig_conv.is_owned = false;
18186         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18187         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
18188         uint64_t ret_ref = 0;
18189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18192         ret_ref = (uint64_t)ret_var.inner;
18193         if (ret_var.is_owned) {
18194                 ret_ref |= 1;
18195         }
18196         return ret_ref;
18197 }
18198
18199 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
18200         LDKNetwork network_conv = LDKNetwork_from_js(network);
18201         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
18202         uint64_t ret_ref = 0;
18203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18206         ret_ref = (uint64_t)ret_var.inner;
18207         if (ret_var.is_owned) {
18208                 ret_ref |= 1;
18209         }
18210         return ret_ref;
18211 }
18212
18213 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
18214         LDKThirtyTwoBytes block_hash_ref;
18215         CHECK(block_hash->arr_len == 32);
18216         memcpy(block_hash_ref.data, block_hash->elems, 32);
18217         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
18218         uint64_t ret_ref = 0;
18219         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18220         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18222         ret_ref = (uint64_t)ret_var.inner;
18223         if (ret_var.is_owned) {
18224                 ret_ref |= 1;
18225         }
18226         return ret_ref;
18227 }
18228
18229 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
18230         LDKBestBlock this_arg_conv;
18231         this_arg_conv.inner = (void*)(this_arg & (~1));
18232         this_arg_conv.is_owned = false;
18233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18234         int8_tArray ret_arr = init_int8_tArray(32);
18235         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
18236         return ret_arr;
18237 }
18238
18239 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
18240         LDKBestBlock this_arg_conv;
18241         this_arg_conv.inner = (void*)(this_arg & (~1));
18242         this_arg_conv.is_owned = false;
18243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18244         int32_t ret_val = BestBlock_height(&this_arg_conv);
18245         return ret_val;
18246 }
18247
18248 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
18249         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
18250         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
18251         return ret_conv;
18252 }
18253
18254 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
18255         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
18256         return ret_conv;
18257 }
18258
18259 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
18260         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
18261         return ret_conv;
18262 }
18263
18264 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
18265         if ((this_ptr & 1) != 0) return;
18266         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18267         CHECK_ACCESS(this_ptr_ptr);
18268         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
18269         FREE((void*)this_ptr);
18270         Access_free(this_ptr_conv);
18271 }
18272
18273 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
18274         if ((this_ptr & 1) != 0) return;
18275         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18276         CHECK_ACCESS(this_ptr_ptr);
18277         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
18278         FREE((void*)this_ptr);
18279         Listen_free(this_ptr_conv);
18280 }
18281
18282 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
18283         if ((this_ptr & 1) != 0) return;
18284         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18285         CHECK_ACCESS(this_ptr_ptr);
18286         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
18287         FREE((void*)this_ptr);
18288         Confirm_free(this_ptr_conv);
18289 }
18290
18291 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
18292         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
18293         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
18294         return ret_conv;
18295 }
18296
18297 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
18298         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
18299         return ret_conv;
18300 }
18301
18302 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
18303         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
18304         return ret_conv;
18305 }
18306
18307 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
18308         if ((this_ptr & 1) != 0) return;
18309         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18310         CHECK_ACCESS(this_ptr_ptr);
18311         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
18312         FREE((void*)this_ptr);
18313         Watch_free(this_ptr_conv);
18314 }
18315
18316 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
18317         if ((this_ptr & 1) != 0) return;
18318         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18319         CHECK_ACCESS(this_ptr_ptr);
18320         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
18321         FREE((void*)this_ptr);
18322         Filter_free(this_ptr_conv);
18323 }
18324
18325 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
18326         LDKWatchedOutput this_obj_conv;
18327         this_obj_conv.inner = (void*)(this_obj & (~1));
18328         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18330         WatchedOutput_free(this_obj_conv);
18331 }
18332
18333 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
18334         LDKWatchedOutput this_ptr_conv;
18335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18336         this_ptr_conv.is_owned = false;
18337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18338         int8_tArray ret_arr = init_int8_tArray(32);
18339         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
18340         return ret_arr;
18341 }
18342
18343 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
18344         LDKWatchedOutput this_ptr_conv;
18345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18346         this_ptr_conv.is_owned = false;
18347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18348         LDKThirtyTwoBytes val_ref;
18349         CHECK(val->arr_len == 32);
18350         memcpy(val_ref.data, val->elems, 32);
18351         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
18352 }
18353
18354 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
18355         LDKWatchedOutput this_ptr_conv;
18356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18357         this_ptr_conv.is_owned = false;
18358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18359         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
18360         uint64_t ret_ref = 0;
18361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18364         ret_ref = (uint64_t)ret_var.inner;
18365         if (ret_var.is_owned) {
18366                 ret_ref |= 1;
18367         }
18368         return ret_ref;
18369 }
18370
18371 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
18372         LDKWatchedOutput this_ptr_conv;
18373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18374         this_ptr_conv.is_owned = false;
18375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18376         LDKOutPoint val_conv;
18377         val_conv.inner = (void*)(val & (~1));
18378         val_conv.is_owned = (val & 1) || (val == 0);
18379         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18380         val_conv = OutPoint_clone(&val_conv);
18381         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
18382 }
18383
18384 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
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         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
18390         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
18391         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18392         return ret_arr;
18393 }
18394
18395 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
18396         LDKWatchedOutput this_ptr_conv;
18397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18398         this_ptr_conv.is_owned = false;
18399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18400         LDKCVec_u8Z val_ref;
18401         val_ref.datalen = val->arr_len;
18402         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18403         memcpy(val_ref.data, val->elems, val_ref.datalen);
18404         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
18405 }
18406
18407 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) {
18408         LDKThirtyTwoBytes block_hash_arg_ref;
18409         CHECK(block_hash_arg->arr_len == 32);
18410         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32);
18411         LDKOutPoint outpoint_arg_conv;
18412         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18413         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18414         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
18415         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18416         LDKCVec_u8Z script_pubkey_arg_ref;
18417         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
18418         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18419         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen);
18420         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
18421         uint64_t ret_ref = 0;
18422         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18423         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18425         ret_ref = (uint64_t)ret_var.inner;
18426         if (ret_var.is_owned) {
18427                 ret_ref |= 1;
18428         }
18429         return ret_ref;
18430 }
18431
18432 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
18433         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
18434 uint64_t ret_ref = 0;
18435 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18436 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
18439 if (ret_var.is_owned) {
18440         ret_ref |= 1;
18441 }
18442         return ret_ref;
18443 }
18444 int64_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
18445         LDKWatchedOutput arg_conv;
18446         arg_conv.inner = (void*)(arg & (~1));
18447         arg_conv.is_owned = false;
18448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18449         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
18450         return ret_val;
18451 }
18452
18453 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
18454         LDKWatchedOutput orig_conv;
18455         orig_conv.inner = (void*)(orig & (~1));
18456         orig_conv.is_owned = false;
18457         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18458         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18459         uint64_t ret_ref = 0;
18460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18463         ret_ref = (uint64_t)ret_var.inner;
18464         if (ret_var.is_owned) {
18465                 ret_ref |= 1;
18466         }
18467         return ret_ref;
18468 }
18469
18470 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
18471         LDKWatchedOutput o_conv;
18472         o_conv.inner = (void*)(o & (~1));
18473         o_conv.is_owned = false;
18474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18475         int64_t ret_val = WatchedOutput_hash(&o_conv);
18476         return ret_val;
18477 }
18478
18479 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
18480         if ((this_ptr & 1) != 0) return;
18481         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18482         CHECK_ACCESS(this_ptr_ptr);
18483         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18484         FREE((void*)this_ptr);
18485         BroadcasterInterface_free(this_ptr_conv);
18486 }
18487
18488 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
18489         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18490         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
18491         return ret_conv;
18492 }
18493
18494 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
18495         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
18496         return ret_conv;
18497 }
18498
18499 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
18500         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
18501         return ret_conv;
18502 }
18503
18504 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
18505         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
18506         return ret_conv;
18507 }
18508
18509 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
18510         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18511         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18512         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18513         return ret_val;
18514 }
18515
18516 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
18517         if ((this_ptr & 1) != 0) return;
18518         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18519         CHECK_ACCESS(this_ptr_ptr);
18520         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18521         FREE((void*)this_ptr);
18522         FeeEstimator_free(this_ptr_conv);
18523 }
18524
18525 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
18526         LDKMonitorUpdateId this_obj_conv;
18527         this_obj_conv.inner = (void*)(this_obj & (~1));
18528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18530         MonitorUpdateId_free(this_obj_conv);
18531 }
18532
18533 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
18534         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
18535 uint64_t ret_ref = 0;
18536 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18537 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18538 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18539 ret_ref = (uint64_t)ret_var.inner;
18540 if (ret_var.is_owned) {
18541         ret_ref |= 1;
18542 }
18543         return ret_ref;
18544 }
18545 int64_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
18546         LDKMonitorUpdateId arg_conv;
18547         arg_conv.inner = (void*)(arg & (~1));
18548         arg_conv.is_owned = false;
18549         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18550         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
18551         return ret_val;
18552 }
18553
18554 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
18555         LDKMonitorUpdateId orig_conv;
18556         orig_conv.inner = (void*)(orig & (~1));
18557         orig_conv.is_owned = false;
18558         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18559         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18560         uint64_t ret_ref = 0;
18561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18564         ret_ref = (uint64_t)ret_var.inner;
18565         if (ret_var.is_owned) {
18566                 ret_ref |= 1;
18567         }
18568         return ret_ref;
18569 }
18570
18571 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
18572         LDKMonitorUpdateId o_conv;
18573         o_conv.inner = (void*)(o & (~1));
18574         o_conv.is_owned = false;
18575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18576         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18577         return ret_val;
18578 }
18579
18580 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
18581         LDKMonitorUpdateId a_conv;
18582         a_conv.inner = (void*)(a & (~1));
18583         a_conv.is_owned = false;
18584         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18585         LDKMonitorUpdateId b_conv;
18586         b_conv.inner = (void*)(b & (~1));
18587         b_conv.is_owned = false;
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18589         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18590         return ret_val;
18591 }
18592
18593 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
18594         if ((this_ptr & 1) != 0) return;
18595         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18596         CHECK_ACCESS(this_ptr_ptr);
18597         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18598         FREE((void*)this_ptr);
18599         Persist_free(this_ptr_conv);
18600 }
18601
18602 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
18603         LDKLockedChannelMonitor this_obj_conv;
18604         this_obj_conv.inner = (void*)(this_obj & (~1));
18605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18607         LockedChannelMonitor_free(this_obj_conv);
18608 }
18609
18610 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
18611         LDKChainMonitor this_obj_conv;
18612         this_obj_conv.inner = (void*)(this_obj & (~1));
18613         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18615         ChainMonitor_free(this_obj_conv);
18616 }
18617
18618 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) {
18619         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
18620         CHECK_ACCESS(chain_source_ptr);
18621         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18622         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18623         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18624                 // Manually implement clone for Java trait instances
18625         }
18626         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18627         CHECK_ACCESS(broadcaster_ptr);
18628         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18629         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18630         CHECK_ACCESS(logger_ptr);
18631         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18632         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
18633         CHECK_ACCESS(feeest_ptr);
18634         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18635         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
18636         CHECK_ACCESS(persister_ptr);
18637         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18638         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18639         uint64_t ret_ref = 0;
18640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18643         ret_ref = (uint64_t)ret_var.inner;
18644         if (ret_var.is_owned) {
18645                 ret_ref |= 1;
18646         }
18647         return ret_ref;
18648 }
18649
18650 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
18651         LDKChainMonitor this_arg_conv;
18652         this_arg_conv.inner = (void*)(this_arg & (~1));
18653         this_arg_conv.is_owned = false;
18654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18655         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18656         ignored_channels_constr.datalen = ignored_channels->arr_len;
18657         if (ignored_channels_constr.datalen > 0)
18658                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18659         else
18660                 ignored_channels_constr.data = NULL;
18661         uint32_t* ignored_channels_vals = ignored_channels->elems;
18662         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18663                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
18664                 LDKChannelDetails ignored_channels_conv_16_conv;
18665                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18666                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18667                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
18668                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18669                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18670         }
18671         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18672         uint32_tArray ret_arr = NULL;
18673         ret_arr = init_uint32_tArray(ret_var.datalen);
18674         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18675         for (size_t j = 0; j < ret_var.datalen; j++) {
18676                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18677                 *ret_conv_9_copy = ret_var.data[j];
18678                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
18679                 ret_arr_ptr[j] = ret_conv_9_ref;
18680         }
18681         
18682         FREE(ret_var.data);
18683         return ret_arr;
18684 }
18685
18686 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
18687         LDKChainMonitor this_arg_conv;
18688         this_arg_conv.inner = (void*)(this_arg & (~1));
18689         this_arg_conv.is_owned = false;
18690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18691         LDKOutPoint funding_txo_conv;
18692         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18693         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18694         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18695         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18696         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18697         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18698         return (uint64_t)ret_conv;
18699 }
18700
18701 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
18702         LDKChainMonitor this_arg_conv;
18703         this_arg_conv.inner = (void*)(this_arg & (~1));
18704         this_arg_conv.is_owned = false;
18705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18706         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18707         uint32_tArray ret_arr = NULL;
18708         ret_arr = init_uint32_tArray(ret_var.datalen);
18709         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18710         for (size_t k = 0; k < ret_var.datalen; k++) {
18711                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18712                 uint64_t ret_conv_10_ref = 0;
18713                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18714                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18715                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
18716                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
18717                 if (ret_conv_10_var.is_owned) {
18718                         ret_conv_10_ref |= 1;
18719                 }
18720                 ret_arr_ptr[k] = ret_conv_10_ref;
18721         }
18722         
18723         FREE(ret_var.data);
18724         return ret_arr;
18725 }
18726
18727 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) {
18728         LDKChainMonitor this_arg_conv;
18729         this_arg_conv.inner = (void*)(this_arg & (~1));
18730         this_arg_conv.is_owned = false;
18731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18732         LDKOutPoint funding_txo_conv;
18733         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18734         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18735         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18736         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18737         LDKMonitorUpdateId completed_update_id_conv;
18738         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18739         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18740         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
18741         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18742         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18743         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18744         return (uint64_t)ret_conv;
18745 }
18746
18747 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
18748         LDKChainMonitor this_arg_conv;
18749         this_arg_conv.inner = (void*)(this_arg & (~1));
18750         this_arg_conv.is_owned = false;
18751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18752         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18753         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18754         return (uint64_t)ret_ret;
18755 }
18756
18757 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
18758         LDKChainMonitor this_arg_conv;
18759         this_arg_conv.inner = (void*)(this_arg & (~1));
18760         this_arg_conv.is_owned = false;
18761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18762         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18763         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18764         return (uint64_t)ret_ret;
18765 }
18766
18767 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
18768         LDKChainMonitor this_arg_conv;
18769         this_arg_conv.inner = (void*)(this_arg & (~1));
18770         this_arg_conv.is_owned = false;
18771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18772         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18773         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18774         return (uint64_t)ret_ret;
18775 }
18776
18777 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
18778         LDKChainMonitor this_arg_conv;
18779         this_arg_conv.inner = (void*)(this_arg & (~1));
18780         this_arg_conv.is_owned = false;
18781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18782         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18783         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18784         return (uint64_t)ret_ret;
18785 }
18786
18787 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
18788         LDKChannelMonitorUpdate this_obj_conv;
18789         this_obj_conv.inner = (void*)(this_obj & (~1));
18790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18792         ChannelMonitorUpdate_free(this_obj_conv);
18793 }
18794
18795 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
18796         LDKChannelMonitorUpdate this_ptr_conv;
18797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18798         this_ptr_conv.is_owned = false;
18799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18800         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18801         return ret_val;
18802 }
18803
18804 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
18805         LDKChannelMonitorUpdate this_ptr_conv;
18806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18807         this_ptr_conv.is_owned = false;
18808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18809         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18810 }
18811
18812 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
18813         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
18814 uint64_t ret_ref = 0;
18815 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18816 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18818 ret_ref = (uint64_t)ret_var.inner;
18819 if (ret_var.is_owned) {
18820         ret_ref |= 1;
18821 }
18822         return ret_ref;
18823 }
18824 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
18825         LDKChannelMonitorUpdate arg_conv;
18826         arg_conv.inner = (void*)(arg & (~1));
18827         arg_conv.is_owned = false;
18828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18829         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
18830         return ret_val;
18831 }
18832
18833 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
18834         LDKChannelMonitorUpdate orig_conv;
18835         orig_conv.inner = (void*)(orig & (~1));
18836         orig_conv.is_owned = false;
18837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18838         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18839         uint64_t ret_ref = 0;
18840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18843         ret_ref = (uint64_t)ret_var.inner;
18844         if (ret_var.is_owned) {
18845                 ret_ref |= 1;
18846         }
18847         return ret_ref;
18848 }
18849
18850 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
18851         LDKChannelMonitorUpdate obj_conv;
18852         obj_conv.inner = (void*)(obj & (~1));
18853         obj_conv.is_owned = false;
18854         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18855         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18856         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
18857         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18858         CVec_u8Z_free(ret_var);
18859         return ret_arr;
18860 }
18861
18862 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
18863         LDKu8slice ser_ref;
18864         ser_ref.datalen = ser->arr_len;
18865         ser_ref.data = ser->elems;
18866         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18867         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
18868         return (uint64_t)ret_conv;
18869 }
18870
18871 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
18872         if ((this_ptr & 1) != 0) return;
18873         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18874         CHECK_ACCESS(this_ptr_ptr);
18875         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
18876         FREE((void*)this_ptr);
18877         MonitorEvent_free(this_ptr_conv);
18878 }
18879
18880 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
18881         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18882         *ret_copy = MonitorEvent_clone(arg);
18883 uint64_t ret_ref = (uint64_t)ret_copy;
18884         return ret_ref;
18885 }
18886 int64_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
18887         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
18888         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
18889         return ret_val;
18890 }
18891
18892 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
18893         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
18894         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18895         *ret_copy = MonitorEvent_clone(orig_conv);
18896         uint64_t ret_ref = (uint64_t)ret_copy;
18897         return ret_ref;
18898 }
18899
18900 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
18901         LDKHTLCUpdate a_conv;
18902         a_conv.inner = (void*)(a & (~1));
18903         a_conv.is_owned = (a & 1) || (a == 0);
18904         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18905         a_conv = HTLCUpdate_clone(&a_conv);
18906         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18907         *ret_copy = MonitorEvent_htlcevent(a_conv);
18908         uint64_t ret_ref = (uint64_t)ret_copy;
18909         return ret_ref;
18910 }
18911
18912 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
18913         LDKOutPoint a_conv;
18914         a_conv.inner = (void*)(a & (~1));
18915         a_conv.is_owned = (a & 1) || (a == 0);
18916         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18917         a_conv = OutPoint_clone(&a_conv);
18918         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18919         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
18920         uint64_t ret_ref = (uint64_t)ret_copy;
18921         return ret_ref;
18922 }
18923
18924 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
18925         LDKOutPoint funding_txo_conv;
18926         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18927         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18928         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18929         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18930         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18931         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
18932         uint64_t ret_ref = (uint64_t)ret_copy;
18933         return ret_ref;
18934 }
18935
18936 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
18937         LDKOutPoint a_conv;
18938         a_conv.inner = (void*)(a & (~1));
18939         a_conv.is_owned = (a & 1) || (a == 0);
18940         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18941         a_conv = OutPoint_clone(&a_conv);
18942         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18943         *ret_copy = MonitorEvent_update_failed(a_conv);
18944         uint64_t ret_ref = (uint64_t)ret_copy;
18945         return ret_ref;
18946 }
18947
18948 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
18949         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
18950         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
18951         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
18952         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18953         CVec_u8Z_free(ret_var);
18954         return ret_arr;
18955 }
18956
18957 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
18958         LDKu8slice ser_ref;
18959         ser_ref.datalen = ser->arr_len;
18960         ser_ref.data = ser->elems;
18961         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18962         *ret_conv = MonitorEvent_read(ser_ref);
18963         return (uint64_t)ret_conv;
18964 }
18965
18966 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
18967         LDKHTLCUpdate this_obj_conv;
18968         this_obj_conv.inner = (void*)(this_obj & (~1));
18969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18971         HTLCUpdate_free(this_obj_conv);
18972 }
18973
18974 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
18975         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
18976 uint64_t ret_ref = 0;
18977 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18978 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18979 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18980 ret_ref = (uint64_t)ret_var.inner;
18981 if (ret_var.is_owned) {
18982         ret_ref |= 1;
18983 }
18984         return ret_ref;
18985 }
18986 int64_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
18987         LDKHTLCUpdate arg_conv;
18988         arg_conv.inner = (void*)(arg & (~1));
18989         arg_conv.is_owned = false;
18990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18991         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
18992         return ret_val;
18993 }
18994
18995 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
18996         LDKHTLCUpdate orig_conv;
18997         orig_conv.inner = (void*)(orig & (~1));
18998         orig_conv.is_owned = false;
18999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19000         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
19001         uint64_t ret_ref = 0;
19002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19005         ret_ref = (uint64_t)ret_var.inner;
19006         if (ret_var.is_owned) {
19007                 ret_ref |= 1;
19008         }
19009         return ret_ref;
19010 }
19011
19012 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
19013         LDKHTLCUpdate obj_conv;
19014         obj_conv.inner = (void*)(obj & (~1));
19015         obj_conv.is_owned = false;
19016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19017         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
19018         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
19019         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19020         CVec_u8Z_free(ret_var);
19021         return ret_arr;
19022 }
19023
19024 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
19025         LDKu8slice ser_ref;
19026         ser_ref.datalen = ser->arr_len;
19027         ser_ref.data = ser->elems;
19028         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19029         *ret_conv = HTLCUpdate_read(ser_ref);
19030         return (uint64_t)ret_conv;
19031 }
19032
19033 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
19034         if ((this_ptr & 1) != 0) return;
19035         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19036         CHECK_ACCESS(this_ptr_ptr);
19037         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
19038         FREE((void*)this_ptr);
19039         Balance_free(this_ptr_conv);
19040 }
19041
19042 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
19043         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19044         *ret_copy = Balance_clone(arg);
19045 uint64_t ret_ref = (uint64_t)ret_copy;
19046         return ret_ref;
19047 }
19048 int64_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
19049         LDKBalance* arg_conv = (LDKBalance*)arg;
19050         int64_t ret_val = Balance_clone_ptr(arg_conv);
19051         return ret_val;
19052 }
19053
19054 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
19055         LDKBalance* orig_conv = (LDKBalance*)orig;
19056         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19057         *ret_copy = Balance_clone(orig_conv);
19058         uint64_t ret_ref = (uint64_t)ret_copy;
19059         return ret_ref;
19060 }
19061
19062 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
19063         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19064         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
19065         uint64_t ret_ref = (uint64_t)ret_copy;
19066         return ret_ref;
19067 }
19068
19069 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
19070         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19071         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
19072         uint64_t ret_ref = (uint64_t)ret_copy;
19073         return ret_ref;
19074 }
19075
19076 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
19077         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19078         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
19079         uint64_t ret_ref = (uint64_t)ret_copy;
19080         return ret_ref;
19081 }
19082
19083 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) {
19084         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19085         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
19086         uint64_t ret_ref = (uint64_t)ret_copy;
19087         return ret_ref;
19088 }
19089
19090 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
19091         LDKBalance* a_conv = (LDKBalance*)a;
19092         LDKBalance* b_conv = (LDKBalance*)b;
19093         jboolean ret_val = Balance_eq(a_conv, b_conv);
19094         return ret_val;
19095 }
19096
19097 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
19098         LDKChannelMonitor this_obj_conv;
19099         this_obj_conv.inner = (void*)(this_obj & (~1));
19100         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19102         ChannelMonitor_free(this_obj_conv);
19103 }
19104
19105 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
19106         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
19107 uint64_t ret_ref = 0;
19108 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19109 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19111 ret_ref = (uint64_t)ret_var.inner;
19112 if (ret_var.is_owned) {
19113         ret_ref |= 1;
19114 }
19115         return ret_ref;
19116 }
19117 int64_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
19118         LDKChannelMonitor arg_conv;
19119         arg_conv.inner = (void*)(arg & (~1));
19120         arg_conv.is_owned = false;
19121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19122         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
19123         return ret_val;
19124 }
19125
19126 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
19127         LDKChannelMonitor orig_conv;
19128         orig_conv.inner = (void*)(orig & (~1));
19129         orig_conv.is_owned = false;
19130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19131         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
19132         uint64_t ret_ref = 0;
19133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19136         ret_ref = (uint64_t)ret_var.inner;
19137         if (ret_var.is_owned) {
19138                 ret_ref |= 1;
19139         }
19140         return ret_ref;
19141 }
19142
19143 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
19144         LDKChannelMonitor obj_conv;
19145         obj_conv.inner = (void*)(obj & (~1));
19146         obj_conv.is_owned = false;
19147         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19148         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
19149         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
19150         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19151         CVec_u8Z_free(ret_var);
19152         return ret_arr;
19153 }
19154
19155 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) {
19156         LDKChannelMonitor this_arg_conv;
19157         this_arg_conv.inner = (void*)(this_arg & (~1));
19158         this_arg_conv.is_owned = false;
19159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19160         LDKChannelMonitorUpdate updates_conv;
19161         updates_conv.inner = (void*)(updates & (~1));
19162         updates_conv.is_owned = false;
19163         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19164         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19165         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
19166         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
19167         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19168         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
19169         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
19170         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19171         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19172         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19173         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
19174         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
19175         return (uint64_t)ret_conv;
19176 }
19177
19178 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
19179         LDKChannelMonitor this_arg_conv;
19180         this_arg_conv.inner = (void*)(this_arg & (~1));
19181         this_arg_conv.is_owned = false;
19182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19183         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
19184         return ret_val;
19185 }
19186
19187 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
19188         LDKChannelMonitor this_arg_conv;
19189         this_arg_conv.inner = (void*)(this_arg & (~1));
19190         this_arg_conv.is_owned = false;
19191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19192         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19193         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
19194         return ((uint64_t)ret_conv);
19195 }
19196
19197 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
19198         LDKChannelMonitor this_arg_conv;
19199         this_arg_conv.inner = (void*)(this_arg & (~1));
19200         this_arg_conv.is_owned = false;
19201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19202         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
19203         uint32_tArray ret_arr = NULL;
19204         ret_arr = init_uint32_tArray(ret_var.datalen);
19205         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19206         for (size_t o = 0; o < ret_var.datalen; o++) {
19207                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19208                 *ret_conv_40_conv = ret_var.data[o];
19209                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
19210         }
19211         
19212         FREE(ret_var.data);
19213         return ret_arr;
19214 }
19215
19216 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
19217         LDKChannelMonitor this_arg_conv;
19218         this_arg_conv.inner = (void*)(this_arg & (~1));
19219         this_arg_conv.is_owned = false;
19220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19221         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
19222         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
19223         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
19224         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
19225 }
19226
19227 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) {
19228         LDKChannelMonitor this_arg_conv;
19229         this_arg_conv.inner = (void*)(this_arg & (~1));
19230         this_arg_conv.is_owned = false;
19231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19232         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
19233         uint32_tArray ret_arr = NULL;
19234         ret_arr = init_uint32_tArray(ret_var.datalen);
19235         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19236         for (size_t o = 0; o < ret_var.datalen; o++) {
19237                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19238                 *ret_conv_14_copy = ret_var.data[o];
19239                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
19240                 ret_arr_ptr[o] = ret_conv_14_ref;
19241         }
19242         
19243         FREE(ret_var.data);
19244         return ret_arr;
19245 }
19246
19247 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
19248         LDKChannelMonitor this_arg_conv;
19249         this_arg_conv.inner = (void*)(this_arg & (~1));
19250         this_arg_conv.is_owned = false;
19251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19252         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
19253         uint32_tArray ret_arr = NULL;
19254         ret_arr = init_uint32_tArray(ret_var.datalen);
19255         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19256         for (size_t h = 0; h < ret_var.datalen; h++) {
19257                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19258                 *ret_conv_7_copy = ret_var.data[h];
19259                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
19260                 ret_arr_ptr[h] = ret_conv_7_ref;
19261         }
19262         
19263         FREE(ret_var.data);
19264         return ret_arr;
19265 }
19266
19267 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) {
19268         LDKChannelMonitor this_arg_conv;
19269         this_arg_conv.inner = (void*)(this_arg & (~1));
19270         this_arg_conv.is_owned = false;
19271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19272         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19273         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19274         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19275         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
19276         ptrArray ret_arr = NULL;
19277         ret_arr = init_ptrArray(ret_var.datalen);
19278         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19279         for (size_t m = 0; m < ret_var.datalen; m++) {
19280                 LDKTransaction ret_conv_12_var = ret_var.data[m];
19281                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen);
19282                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
19283                 Transaction_free(ret_conv_12_var);
19284                 ret_arr_ptr[m] = ret_conv_12_arr;
19285         }
19286         
19287         FREE(ret_var.data);
19288         return ret_arr;
19289 }
19290
19291 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) {
19292         LDKChannelMonitor this_arg_conv;
19293         this_arg_conv.inner = (void*)(this_arg & (~1));
19294         this_arg_conv.is_owned = false;
19295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19296         unsigned char header_arr[80];
19297         CHECK(header->arr_len == 80);
19298         memcpy(header_arr, header->elems, 80);
19299         unsigned char (*header_ref)[80] = &header_arr;
19300         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19301         txdata_constr.datalen = txdata->arr_len;
19302         if (txdata_constr.datalen > 0)
19303                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19304         else
19305                 txdata_constr.data = NULL;
19306         uint32_t* txdata_vals = txdata->elems;
19307         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19308                 uint32_t txdata_conv_28 = txdata_vals[c];
19309                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19310                 CHECK_ACCESS(txdata_conv_28_ptr);
19311                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19312                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19313                 txdata_constr.data[c] = txdata_conv_28_conv;
19314         }
19315         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19316         CHECK_ACCESS(broadcaster_ptr);
19317         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19318         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19319         CHECK_ACCESS(fee_estimator_ptr);
19320         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19321         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19322         CHECK_ACCESS(logger_ptr);
19323         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19324         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);
19325         uint32_tArray ret_arr = NULL;
19326         ret_arr = init_uint32_tArray(ret_var.datalen);
19327         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19328         for (size_t n = 0; n < ret_var.datalen; n++) {
19329                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19330                 *ret_conv_39_conv = ret_var.data[n];
19331                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19332         }
19333         
19334         FREE(ret_var.data);
19335         return ret_arr;
19336 }
19337
19338 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) {
19339         LDKChannelMonitor this_arg_conv;
19340         this_arg_conv.inner = (void*)(this_arg & (~1));
19341         this_arg_conv.is_owned = false;
19342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19343         unsigned char header_arr[80];
19344         CHECK(header->arr_len == 80);
19345         memcpy(header_arr, header->elems, 80);
19346         unsigned char (*header_ref)[80] = &header_arr;
19347         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19348         CHECK_ACCESS(broadcaster_ptr);
19349         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19350         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19351         CHECK_ACCESS(fee_estimator_ptr);
19352         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19353         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19354         CHECK_ACCESS(logger_ptr);
19355         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19356         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19357 }
19358
19359 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) {
19360         LDKChannelMonitor this_arg_conv;
19361         this_arg_conv.inner = (void*)(this_arg & (~1));
19362         this_arg_conv.is_owned = false;
19363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19364         unsigned char header_arr[80];
19365         CHECK(header->arr_len == 80);
19366         memcpy(header_arr, header->elems, 80);
19367         unsigned char (*header_ref)[80] = &header_arr;
19368         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19369         txdata_constr.datalen = txdata->arr_len;
19370         if (txdata_constr.datalen > 0)
19371                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19372         else
19373                 txdata_constr.data = NULL;
19374         uint32_t* txdata_vals = txdata->elems;
19375         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19376                 uint32_t txdata_conv_28 = txdata_vals[c];
19377                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19378                 CHECK_ACCESS(txdata_conv_28_ptr);
19379                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19380                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19381                 txdata_constr.data[c] = txdata_conv_28_conv;
19382         }
19383         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19384         CHECK_ACCESS(broadcaster_ptr);
19385         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19386         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19387         CHECK_ACCESS(fee_estimator_ptr);
19388         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19389         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19390         CHECK_ACCESS(logger_ptr);
19391         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19392         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);
19393         uint32_tArray ret_arr = NULL;
19394         ret_arr = init_uint32_tArray(ret_var.datalen);
19395         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19396         for (size_t n = 0; n < ret_var.datalen; n++) {
19397                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19398                 *ret_conv_39_conv = ret_var.data[n];
19399                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19400         }
19401         
19402         FREE(ret_var.data);
19403         return ret_arr;
19404 }
19405
19406 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) {
19407         LDKChannelMonitor this_arg_conv;
19408         this_arg_conv.inner = (void*)(this_arg & (~1));
19409         this_arg_conv.is_owned = false;
19410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19411         unsigned char txid_arr[32];
19412         CHECK(txid->arr_len == 32);
19413         memcpy(txid_arr, txid->elems, 32);
19414         unsigned char (*txid_ref)[32] = &txid_arr;
19415         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19416         CHECK_ACCESS(broadcaster_ptr);
19417         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19418         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19419         CHECK_ACCESS(fee_estimator_ptr);
19420         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19421         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19422         CHECK_ACCESS(logger_ptr);
19423         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19424         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19425 }
19426
19427 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) {
19428         LDKChannelMonitor this_arg_conv;
19429         this_arg_conv.inner = (void*)(this_arg & (~1));
19430         this_arg_conv.is_owned = false;
19431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19432         unsigned char header_arr[80];
19433         CHECK(header->arr_len == 80);
19434         memcpy(header_arr, header->elems, 80);
19435         unsigned char (*header_ref)[80] = &header_arr;
19436         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19437         CHECK_ACCESS(broadcaster_ptr);
19438         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19439         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19440         CHECK_ACCESS(fee_estimator_ptr);
19441         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19442         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19443         CHECK_ACCESS(logger_ptr);
19444         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19445         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19446         uint32_tArray ret_arr = NULL;
19447         ret_arr = init_uint32_tArray(ret_var.datalen);
19448         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19449         for (size_t n = 0; n < ret_var.datalen; n++) {
19450                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19451                 *ret_conv_39_conv = ret_var.data[n];
19452                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19453         }
19454         
19455         FREE(ret_var.data);
19456         return ret_arr;
19457 }
19458
19459 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
19460         LDKChannelMonitor this_arg_conv;
19461         this_arg_conv.inner = (void*)(this_arg & (~1));
19462         this_arg_conv.is_owned = false;
19463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19464         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19465         ptrArray ret_arr = NULL;
19466         ret_arr = init_ptrArray(ret_var.datalen);
19467         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19468         for (size_t m = 0; m < ret_var.datalen; m++) {
19469                 int8_tArray ret_conv_12_arr = init_int8_tArray(32);
19470                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
19471                 ret_arr_ptr[m] = ret_conv_12_arr;
19472         }
19473         
19474         FREE(ret_var.data);
19475         return ret_arr;
19476 }
19477
19478 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
19479         LDKChannelMonitor this_arg_conv;
19480         this_arg_conv.inner = (void*)(this_arg & (~1));
19481         this_arg_conv.is_owned = false;
19482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19483         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19484         uint64_t ret_ref = 0;
19485         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19486         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19488         ret_ref = (uint64_t)ret_var.inner;
19489         if (ret_var.is_owned) {
19490                 ret_ref |= 1;
19491         }
19492         return ret_ref;
19493 }
19494
19495 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
19496         LDKChannelMonitor this_arg_conv;
19497         this_arg_conv.inner = (void*)(this_arg & (~1));
19498         this_arg_conv.is_owned = false;
19499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19500         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19501         uint32_tArray ret_arr = NULL;
19502         ret_arr = init_uint32_tArray(ret_var.datalen);
19503         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19504         for (size_t j = 0; j < ret_var.datalen; j++) {
19505                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19506                 *ret_conv_9_copy = ret_var.data[j];
19507                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
19508                 ret_arr_ptr[j] = ret_conv_9_ref;
19509         }
19510         
19511         FREE(ret_var.data);
19512         return ret_arr;
19513 }
19514
19515 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
19516         LDKu8slice ser_ref;
19517         ser_ref.datalen = ser->arr_len;
19518         ser_ref.data = ser->elems;
19519         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
19520         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19521         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19522         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19523         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19524         return (uint64_t)ret_conv;
19525 }
19526
19527 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
19528         LDKOutPoint this_obj_conv;
19529         this_obj_conv.inner = (void*)(this_obj & (~1));
19530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19532         OutPoint_free(this_obj_conv);
19533 }
19534
19535 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
19536         LDKOutPoint this_ptr_conv;
19537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19538         this_ptr_conv.is_owned = false;
19539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19540         int8_tArray ret_arr = init_int8_tArray(32);
19541         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
19542         return ret_arr;
19543 }
19544
19545 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
19546         LDKOutPoint this_ptr_conv;
19547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19548         this_ptr_conv.is_owned = false;
19549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19550         LDKThirtyTwoBytes val_ref;
19551         CHECK(val->arr_len == 32);
19552         memcpy(val_ref.data, val->elems, 32);
19553         OutPoint_set_txid(&this_ptr_conv, val_ref);
19554 }
19555
19556 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
19557         LDKOutPoint this_ptr_conv;
19558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19559         this_ptr_conv.is_owned = false;
19560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19561         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19562         return ret_val;
19563 }
19564
19565 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
19566         LDKOutPoint this_ptr_conv;
19567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19568         this_ptr_conv.is_owned = false;
19569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19570         OutPoint_set_index(&this_ptr_conv, val);
19571 }
19572
19573 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
19574         LDKThirtyTwoBytes txid_arg_ref;
19575         CHECK(txid_arg->arr_len == 32);
19576         memcpy(txid_arg_ref.data, txid_arg->elems, 32);
19577         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19578         uint64_t ret_ref = 0;
19579         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19580         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19582         ret_ref = (uint64_t)ret_var.inner;
19583         if (ret_var.is_owned) {
19584                 ret_ref |= 1;
19585         }
19586         return ret_ref;
19587 }
19588
19589 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
19590         LDKOutPoint ret_var = OutPoint_clone(arg);
19591 uint64_t ret_ref = 0;
19592 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19593 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
19596 if (ret_var.is_owned) {
19597         ret_ref |= 1;
19598 }
19599         return ret_ref;
19600 }
19601 int64_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
19602         LDKOutPoint arg_conv;
19603         arg_conv.inner = (void*)(arg & (~1));
19604         arg_conv.is_owned = false;
19605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19606         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
19607         return ret_val;
19608 }
19609
19610 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
19611         LDKOutPoint orig_conv;
19612         orig_conv.inner = (void*)(orig & (~1));
19613         orig_conv.is_owned = false;
19614         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19615         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19616         uint64_t ret_ref = 0;
19617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19620         ret_ref = (uint64_t)ret_var.inner;
19621         if (ret_var.is_owned) {
19622                 ret_ref |= 1;
19623         }
19624         return ret_ref;
19625 }
19626
19627 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
19628         LDKOutPoint a_conv;
19629         a_conv.inner = (void*)(a & (~1));
19630         a_conv.is_owned = false;
19631         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19632         LDKOutPoint b_conv;
19633         b_conv.inner = (void*)(b & (~1));
19634         b_conv.is_owned = false;
19635         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19636         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19637         return ret_val;
19638 }
19639
19640 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
19641         LDKOutPoint o_conv;
19642         o_conv.inner = (void*)(o & (~1));
19643         o_conv.is_owned = false;
19644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19645         int64_t ret_val = OutPoint_hash(&o_conv);
19646         return ret_val;
19647 }
19648
19649 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
19650         LDKOutPoint this_arg_conv;
19651         this_arg_conv.inner = (void*)(this_arg & (~1));
19652         this_arg_conv.is_owned = false;
19653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19654         int8_tArray ret_arr = init_int8_tArray(32);
19655         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
19656         return ret_arr;
19657 }
19658
19659 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
19660         LDKOutPoint obj_conv;
19661         obj_conv.inner = (void*)(obj & (~1));
19662         obj_conv.is_owned = false;
19663         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19664         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19665         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
19666         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19667         CVec_u8Z_free(ret_var);
19668         return ret_arr;
19669 }
19670
19671 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
19672         LDKu8slice ser_ref;
19673         ser_ref.datalen = ser->arr_len;
19674         ser_ref.data = ser->elems;
19675         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19676         *ret_conv = OutPoint_read(ser_ref);
19677         return (uint64_t)ret_conv;
19678 }
19679
19680 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
19681         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19682         this_obj_conv.inner = (void*)(this_obj & (~1));
19683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19685         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19686 }
19687
19688 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19689         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19691         this_ptr_conv.is_owned = false;
19692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19693         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19694         uint64_t ret_ref = 0;
19695         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19696         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19698         ret_ref = (uint64_t)ret_var.inner;
19699         if (ret_var.is_owned) {
19700                 ret_ref |= 1;
19701         }
19702         return ret_ref;
19703 }
19704
19705 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19706         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19708         this_ptr_conv.is_owned = false;
19709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19710         LDKOutPoint val_conv;
19711         val_conv.inner = (void*)(val & (~1));
19712         val_conv.is_owned = (val & 1) || (val == 0);
19713         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19714         val_conv = OutPoint_clone(&val_conv);
19715         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19716 }
19717
19718 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(33);
19724         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19725         return ret_arr;
19726 }
19727
19728 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19729         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19731         this_ptr_conv.is_owned = false;
19732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19733         LDKPublicKey val_ref;
19734         CHECK(val->arr_len == 33);
19735         memcpy(val_ref.compressed_form, val->elems, 33);
19736         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19737 }
19738
19739 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
19740         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19744         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19745         return ret_val;
19746 }
19747
19748 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19749         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19751         this_ptr_conv.is_owned = false;
19752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19753         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19754 }
19755
19756 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19757         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19759         this_ptr_conv.is_owned = false;
19760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19761         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19762         CHECK_ACCESS(val_ptr);
19763         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19764         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19765         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19766 }
19767
19768 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
19769         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19771         this_ptr_conv.is_owned = false;
19772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19773         int8_tArray ret_arr = init_int8_tArray(33);
19774         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
19775         return ret_arr;
19776 }
19777
19778 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
19779         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19781         this_ptr_conv.is_owned = false;
19782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19783         LDKPublicKey val_ref;
19784         CHECK(val->arr_len == 33);
19785         memcpy(val_ref.compressed_form, val->elems, 33);
19786         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19787 }
19788
19789 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19790         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19792         this_ptr_conv.is_owned = false;
19793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19794         int8_tArray ret_arr = init_int8_tArray(32);
19795         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19796         return ret_arr;
19797 }
19798
19799 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19800         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19802         this_ptr_conv.is_owned = false;
19803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19804         LDKThirtyTwoBytes val_ref;
19805         CHECK(val->arr_len == 32);
19806         memcpy(val_ref.data, val->elems, 32);
19807         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19808 }
19809
19810 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19811         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19813         this_ptr_conv.is_owned = false;
19814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19815         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19816         return ret_val;
19817 }
19818
19819 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19820         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19822         this_ptr_conv.is_owned = false;
19823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19824         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19825 }
19826
19827 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) {
19828         LDKOutPoint outpoint_arg_conv;
19829         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19830         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19831         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19832         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19833         LDKPublicKey per_commitment_point_arg_ref;
19834         CHECK(per_commitment_point_arg->arr_len == 33);
19835         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33);
19836         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
19837         CHECK_ACCESS(output_arg_ptr);
19838         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19839         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
19840         LDKPublicKey revocation_pubkey_arg_ref;
19841         CHECK(revocation_pubkey_arg->arr_len == 33);
19842         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33);
19843         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19844         CHECK(channel_keys_id_arg->arr_len == 32);
19845         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32);
19846         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);
19847         uint64_t ret_ref = 0;
19848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19851         ret_ref = (uint64_t)ret_var.inner;
19852         if (ret_var.is_owned) {
19853                 ret_ref |= 1;
19854         }
19855         return ret_ref;
19856 }
19857
19858 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
19859         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
19860 uint64_t ret_ref = 0;
19861 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19862 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
19865 if (ret_var.is_owned) {
19866         ret_ref |= 1;
19867 }
19868         return ret_ref;
19869 }
19870 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
19871         LDKDelayedPaymentOutputDescriptor arg_conv;
19872         arg_conv.inner = (void*)(arg & (~1));
19873         arg_conv.is_owned = false;
19874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19875         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
19876         return ret_val;
19877 }
19878
19879 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
19880         LDKDelayedPaymentOutputDescriptor orig_conv;
19881         orig_conv.inner = (void*)(orig & (~1));
19882         orig_conv.is_owned = false;
19883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19884         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
19885         uint64_t ret_ref = 0;
19886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19889         ret_ref = (uint64_t)ret_var.inner;
19890         if (ret_var.is_owned) {
19891                 ret_ref |= 1;
19892         }
19893         return ret_ref;
19894 }
19895
19896 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
19897         LDKDelayedPaymentOutputDescriptor obj_conv;
19898         obj_conv.inner = (void*)(obj & (~1));
19899         obj_conv.is_owned = false;
19900         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19901         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
19902         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
19903         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19904         CVec_u8Z_free(ret_var);
19905         return ret_arr;
19906 }
19907
19908 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
19909         LDKu8slice ser_ref;
19910         ser_ref.datalen = ser->arr_len;
19911         ser_ref.data = ser->elems;
19912         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19913         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
19914         return (uint64_t)ret_conv;
19915 }
19916
19917 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
19918         LDKStaticPaymentOutputDescriptor this_obj_conv;
19919         this_obj_conv.inner = (void*)(this_obj & (~1));
19920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19922         StaticPaymentOutputDescriptor_free(this_obj_conv);
19923 }
19924
19925 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19926         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19928         this_ptr_conv.is_owned = false;
19929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19930         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19931         uint64_t ret_ref = 0;
19932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19935         ret_ref = (uint64_t)ret_var.inner;
19936         if (ret_var.is_owned) {
19937                 ret_ref |= 1;
19938         }
19939         return ret_ref;
19940 }
19941
19942 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19943         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19945         this_ptr_conv.is_owned = false;
19946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19947         LDKOutPoint val_conv;
19948         val_conv.inner = (void*)(val & (~1));
19949         val_conv.is_owned = (val & 1) || (val == 0);
19950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19951         val_conv = OutPoint_clone(&val_conv);
19952         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19953 }
19954
19955 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(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         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19961         CHECK_ACCESS(val_ptr);
19962         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19963         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19964         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19965 }
19966
19967 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19968         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19970         this_ptr_conv.is_owned = false;
19971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19972         int8_tArray ret_arr = init_int8_tArray(32);
19973         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19974         return ret_arr;
19975 }
19976
19977 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19978         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19980         this_ptr_conv.is_owned = false;
19981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19982         LDKThirtyTwoBytes val_ref;
19983         CHECK(val->arr_len == 32);
19984         memcpy(val_ref.data, val->elems, 32);
19985         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19986 }
19987
19988 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19989         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19991         this_ptr_conv.is_owned = false;
19992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19993         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19994         return ret_val;
19995 }
19996
19997 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19998         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20000         this_ptr_conv.is_owned = false;
20001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20002         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
20003 }
20004
20005 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) {
20006         LDKOutPoint outpoint_arg_conv;
20007         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
20008         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
20009         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
20010         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
20011         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
20012         CHECK_ACCESS(output_arg_ptr);
20013         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
20014         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
20015         LDKThirtyTwoBytes channel_keys_id_arg_ref;
20016         CHECK(channel_keys_id_arg->arr_len == 32);
20017         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32);
20018         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
20019         uint64_t ret_ref = 0;
20020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20023         ret_ref = (uint64_t)ret_var.inner;
20024         if (ret_var.is_owned) {
20025                 ret_ref |= 1;
20026         }
20027         return ret_ref;
20028 }
20029
20030 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
20031         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
20032 uint64_t ret_ref = 0;
20033 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20034 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
20037 if (ret_var.is_owned) {
20038         ret_ref |= 1;
20039 }
20040         return ret_ref;
20041 }
20042 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
20043         LDKStaticPaymentOutputDescriptor arg_conv;
20044         arg_conv.inner = (void*)(arg & (~1));
20045         arg_conv.is_owned = false;
20046         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20047         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
20048         return ret_val;
20049 }
20050
20051 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
20052         LDKStaticPaymentOutputDescriptor orig_conv;
20053         orig_conv.inner = (void*)(orig & (~1));
20054         orig_conv.is_owned = false;
20055         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20056         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
20057         uint64_t ret_ref = 0;
20058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20061         ret_ref = (uint64_t)ret_var.inner;
20062         if (ret_var.is_owned) {
20063                 ret_ref |= 1;
20064         }
20065         return ret_ref;
20066 }
20067
20068 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
20069         LDKStaticPaymentOutputDescriptor obj_conv;
20070         obj_conv.inner = (void*)(obj & (~1));
20071         obj_conv.is_owned = false;
20072         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20073         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
20074         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
20075         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20076         CVec_u8Z_free(ret_var);
20077         return ret_arr;
20078 }
20079
20080 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
20081         LDKu8slice ser_ref;
20082         ser_ref.datalen = ser->arr_len;
20083         ser_ref.data = ser->elems;
20084         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20085         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
20086         return (uint64_t)ret_conv;
20087 }
20088
20089 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
20090         if ((this_ptr & 1) != 0) return;
20091         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20092         CHECK_ACCESS(this_ptr_ptr);
20093         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
20094         FREE((void*)this_ptr);
20095         SpendableOutputDescriptor_free(this_ptr_conv);
20096 }
20097
20098 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
20099         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20100         *ret_copy = SpendableOutputDescriptor_clone(arg);
20101 uint64_t ret_ref = (uint64_t)ret_copy;
20102         return ret_ref;
20103 }
20104 int64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
20105         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
20106         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
20107         return ret_val;
20108 }
20109
20110 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
20111         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
20112         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20113         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
20114         uint64_t ret_ref = (uint64_t)ret_copy;
20115         return ret_ref;
20116 }
20117
20118 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
20119         LDKOutPoint outpoint_conv;
20120         outpoint_conv.inner = (void*)(outpoint & (~1));
20121         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
20122         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
20123         outpoint_conv = OutPoint_clone(&outpoint_conv);
20124         void* output_ptr = (void*)(((uint64_t)output) & ~1);
20125         CHECK_ACCESS(output_ptr);
20126         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
20127         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
20128         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20129         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
20130         uint64_t ret_ref = (uint64_t)ret_copy;
20131         return ret_ref;
20132 }
20133
20134 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
20135         LDKDelayedPaymentOutputDescriptor a_conv;
20136         a_conv.inner = (void*)(a & (~1));
20137         a_conv.is_owned = (a & 1) || (a == 0);
20138         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20139         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
20140         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20141         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
20142         uint64_t ret_ref = (uint64_t)ret_copy;
20143         return ret_ref;
20144 }
20145
20146 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
20147         LDKStaticPaymentOutputDescriptor a_conv;
20148         a_conv.inner = (void*)(a & (~1));
20149         a_conv.is_owned = (a & 1) || (a == 0);
20150         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20151         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
20152         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20153         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
20154         uint64_t ret_ref = (uint64_t)ret_copy;
20155         return ret_ref;
20156 }
20157
20158 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
20159         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
20160         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
20161         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
20162         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20163         CVec_u8Z_free(ret_var);
20164         return ret_arr;
20165 }
20166
20167 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
20168         LDKu8slice ser_ref;
20169         ser_ref.datalen = ser->arr_len;
20170         ser_ref.data = ser->elems;
20171         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20172         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
20173         return (uint64_t)ret_conv;
20174 }
20175
20176 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
20177         if ((this_ptr & 1) != 0) return;
20178         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20179         CHECK_ACCESS(this_ptr_ptr);
20180         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
20181         FREE((void*)this_ptr);
20182         BaseSign_free(this_ptr_conv);
20183 }
20184
20185 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
20186         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20187         *ret_ret = Sign_clone(arg);
20188         return (uint64_t)ret_ret;
20189 }
20190 int64_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
20191         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
20192         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
20193         LDKSign* arg_conv = (LDKSign*)arg_ptr;
20194         int64_t ret_val = Sign_clone_ptr(arg_conv);
20195         return ret_val;
20196 }
20197
20198 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
20199         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
20200         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
20201         LDKSign* orig_conv = (LDKSign*)orig_ptr;
20202         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20203         *ret_ret = Sign_clone(orig_conv);
20204         return (uint64_t)ret_ret;
20205 }
20206
20207 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
20208         if ((this_ptr & 1) != 0) return;
20209         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20210         CHECK_ACCESS(this_ptr_ptr);
20211         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
20212         FREE((void*)this_ptr);
20213         Sign_free(this_ptr_conv);
20214 }
20215
20216 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
20217         if ((this_ptr & 1) != 0) return;
20218         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20219         CHECK_ACCESS(this_ptr_ptr);
20220         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
20221         FREE((void*)this_ptr);
20222         KeysInterface_free(this_ptr_conv);
20223 }
20224
20225 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
20226         LDKInMemorySigner this_obj_conv;
20227         this_obj_conv.inner = (void*)(this_obj & (~1));
20228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20230         InMemorySigner_free(this_obj_conv);
20231 }
20232
20233 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
20234         LDKInMemorySigner this_ptr_conv;
20235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20236         this_ptr_conv.is_owned = false;
20237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20238         int8_tArray ret_arr = init_int8_tArray(32);
20239         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
20240         return ret_arr;
20241 }
20242
20243 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
20244         LDKInMemorySigner this_ptr_conv;
20245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20246         this_ptr_conv.is_owned = false;
20247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20248         LDKSecretKey val_ref;
20249         CHECK(val->arr_len == 32);
20250         memcpy(val_ref.bytes, val->elems, 32);
20251         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
20252 }
20253
20254 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
20255         LDKInMemorySigner this_ptr_conv;
20256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20257         this_ptr_conv.is_owned = false;
20258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20259         int8_tArray ret_arr = init_int8_tArray(32);
20260         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
20261         return ret_arr;
20262 }
20263
20264 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
20265         LDKInMemorySigner this_ptr_conv;
20266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20267         this_ptr_conv.is_owned = false;
20268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20269         LDKSecretKey val_ref;
20270         CHECK(val->arr_len == 32);
20271         memcpy(val_ref.bytes, val->elems, 32);
20272         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
20273 }
20274
20275 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
20276         LDKInMemorySigner this_ptr_conv;
20277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20278         this_ptr_conv.is_owned = false;
20279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20280         int8_tArray ret_arr = init_int8_tArray(32);
20281         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
20282         return ret_arr;
20283 }
20284
20285 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
20286         LDKInMemorySigner this_ptr_conv;
20287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20288         this_ptr_conv.is_owned = false;
20289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20290         LDKSecretKey val_ref;
20291         CHECK(val->arr_len == 32);
20292         memcpy(val_ref.bytes, val->elems, 32);
20293         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
20294 }
20295
20296 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
20297         LDKInMemorySigner this_ptr_conv;
20298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20299         this_ptr_conv.is_owned = false;
20300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20301         int8_tArray ret_arr = init_int8_tArray(32);
20302         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
20303         return ret_arr;
20304 }
20305
20306 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) {
20307         LDKInMemorySigner this_ptr_conv;
20308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20309         this_ptr_conv.is_owned = false;
20310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20311         LDKSecretKey val_ref;
20312         CHECK(val->arr_len == 32);
20313         memcpy(val_ref.bytes, val->elems, 32);
20314         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
20315 }
20316
20317 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
20318         LDKInMemorySigner this_ptr_conv;
20319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20320         this_ptr_conv.is_owned = false;
20321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20322         int8_tArray ret_arr = init_int8_tArray(32);
20323         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
20324         return ret_arr;
20325 }
20326
20327 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
20328         LDKInMemorySigner this_ptr_conv;
20329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20330         this_ptr_conv.is_owned = false;
20331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20332         LDKSecretKey val_ref;
20333         CHECK(val->arr_len == 32);
20334         memcpy(val_ref.bytes, val->elems, 32);
20335         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
20336 }
20337
20338 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
20339         LDKInMemorySigner this_ptr_conv;
20340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20341         this_ptr_conv.is_owned = false;
20342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20343         int8_tArray ret_arr = init_int8_tArray(32);
20344         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
20345         return ret_arr;
20346 }
20347
20348 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
20349         LDKInMemorySigner this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20353         LDKThirtyTwoBytes val_ref;
20354         CHECK(val->arr_len == 32);
20355         memcpy(val_ref.data, val->elems, 32);
20356         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
20357 }
20358
20359 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
20360         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
20361 uint64_t ret_ref = 0;
20362 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20363 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20364 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20365 ret_ref = (uint64_t)ret_var.inner;
20366 if (ret_var.is_owned) {
20367         ret_ref |= 1;
20368 }
20369         return ret_ref;
20370 }
20371 int64_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
20372         LDKInMemorySigner arg_conv;
20373         arg_conv.inner = (void*)(arg & (~1));
20374         arg_conv.is_owned = false;
20375         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20376         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
20377         return ret_val;
20378 }
20379
20380 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
20381         LDKInMemorySigner orig_conv;
20382         orig_conv.inner = (void*)(orig & (~1));
20383         orig_conv.is_owned = false;
20384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20385         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20386         uint64_t ret_ref = 0;
20387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20390         ret_ref = (uint64_t)ret_var.inner;
20391         if (ret_var.is_owned) {
20392                 ret_ref |= 1;
20393         }
20394         return ret_ref;
20395 }
20396
20397 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) {
20398         LDKSecretKey funding_key_ref;
20399         CHECK(funding_key->arr_len == 32);
20400         memcpy(funding_key_ref.bytes, funding_key->elems, 32);
20401         LDKSecretKey revocation_base_key_ref;
20402         CHECK(revocation_base_key->arr_len == 32);
20403         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32);
20404         LDKSecretKey payment_key_ref;
20405         CHECK(payment_key->arr_len == 32);
20406         memcpy(payment_key_ref.bytes, payment_key->elems, 32);
20407         LDKSecretKey delayed_payment_base_key_ref;
20408         CHECK(delayed_payment_base_key->arr_len == 32);
20409         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32);
20410         LDKSecretKey htlc_base_key_ref;
20411         CHECK(htlc_base_key->arr_len == 32);
20412         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32);
20413         LDKThirtyTwoBytes commitment_seed_ref;
20414         CHECK(commitment_seed->arr_len == 32);
20415         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32);
20416         LDKThirtyTwoBytes channel_keys_id_ref;
20417         CHECK(channel_keys_id->arr_len == 32);
20418         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32);
20419         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);
20420         uint64_t ret_ref = 0;
20421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20424         ret_ref = (uint64_t)ret_var.inner;
20425         if (ret_var.is_owned) {
20426                 ret_ref |= 1;
20427         }
20428         return ret_ref;
20429 }
20430
20431 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
20432         LDKInMemorySigner this_arg_conv;
20433         this_arg_conv.inner = (void*)(this_arg & (~1));
20434         this_arg_conv.is_owned = false;
20435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20436         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20437         uint64_t ret_ref = 0;
20438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20441         ret_ref = (uint64_t)ret_var.inner;
20442         if (ret_var.is_owned) {
20443                 ret_ref |= 1;
20444         }
20445         return ret_ref;
20446 }
20447
20448 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
20449         LDKInMemorySigner this_arg_conv;
20450         this_arg_conv.inner = (void*)(this_arg & (~1));
20451         this_arg_conv.is_owned = false;
20452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20453         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20454         return ret_val;
20455 }
20456
20457 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
20458         LDKInMemorySigner this_arg_conv;
20459         this_arg_conv.inner = (void*)(this_arg & (~1));
20460         this_arg_conv.is_owned = false;
20461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20462         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20463         return ret_val;
20464 }
20465
20466 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
20467         LDKInMemorySigner this_arg_conv;
20468         this_arg_conv.inner = (void*)(this_arg & (~1));
20469         this_arg_conv.is_owned = false;
20470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20471         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20472         return ret_val;
20473 }
20474
20475 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
20476         LDKInMemorySigner this_arg_conv;
20477         this_arg_conv.inner = (void*)(this_arg & (~1));
20478         this_arg_conv.is_owned = false;
20479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20480         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20481         uint64_t ret_ref = 0;
20482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20485         ret_ref = (uint64_t)ret_var.inner;
20486         if (ret_var.is_owned) {
20487                 ret_ref |= 1;
20488         }
20489         return ret_ref;
20490 }
20491
20492 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
20493         LDKInMemorySigner this_arg_conv;
20494         this_arg_conv.inner = (void*)(this_arg & (~1));
20495         this_arg_conv.is_owned = false;
20496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20497         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20498         uint64_t ret_ref = 0;
20499         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20500         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20502         ret_ref = (uint64_t)ret_var.inner;
20503         if (ret_var.is_owned) {
20504                 ret_ref |= 1;
20505         }
20506         return ret_ref;
20507 }
20508
20509 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
20510         LDKInMemorySigner this_arg_conv;
20511         this_arg_conv.inner = (void*)(this_arg & (~1));
20512         this_arg_conv.is_owned = false;
20513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20514         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
20515         return ret_val;
20516 }
20517
20518 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, int64_t input_idx, uint32_t descriptor) {
20519         LDKInMemorySigner this_arg_conv;
20520         this_arg_conv.inner = (void*)(this_arg & (~1));
20521         this_arg_conv.is_owned = false;
20522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20523         LDKTransaction spend_tx_ref;
20524         spend_tx_ref.datalen = spend_tx->arr_len;
20525         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20526         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen);
20527         spend_tx_ref.data_is_owned = true;
20528         LDKStaticPaymentOutputDescriptor descriptor_conv;
20529         descriptor_conv.inner = (void*)(descriptor & (~1));
20530         descriptor_conv.is_owned = false;
20531         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20532         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20533         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20534         return (uint64_t)ret_conv;
20535 }
20536
20537 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, int64_t input_idx, uint32_t descriptor) {
20538         LDKInMemorySigner this_arg_conv;
20539         this_arg_conv.inner = (void*)(this_arg & (~1));
20540         this_arg_conv.is_owned = false;
20541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20542         LDKTransaction spend_tx_ref;
20543         spend_tx_ref.datalen = spend_tx->arr_len;
20544         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20545         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen);
20546         spend_tx_ref.data_is_owned = true;
20547         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20548         descriptor_conv.inner = (void*)(descriptor & (~1));
20549         descriptor_conv.is_owned = false;
20550         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20551         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20552         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20553         return (uint64_t)ret_conv;
20554 }
20555
20556 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
20557         LDKInMemorySigner this_arg_conv;
20558         this_arg_conv.inner = (void*)(this_arg & (~1));
20559         this_arg_conv.is_owned = false;
20560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20561         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20562         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20563         return (uint64_t)ret_ret;
20564 }
20565
20566 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
20567         LDKInMemorySigner this_arg_conv;
20568         this_arg_conv.inner = (void*)(this_arg & (~1));
20569         this_arg_conv.is_owned = false;
20570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20571         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20572         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20573         return (uint64_t)ret_ret;
20574 }
20575
20576 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
20577         LDKInMemorySigner obj_conv;
20578         obj_conv.inner = (void*)(obj & (~1));
20579         obj_conv.is_owned = false;
20580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20581         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
20583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20584         CVec_u8Z_free(ret_var);
20585         return ret_arr;
20586 }
20587
20588 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser) {
20589         LDKu8slice ser_ref;
20590         ser_ref.datalen = ser->arr_len;
20591         ser_ref.data = ser->elems;
20592         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20593         *ret_conv = InMemorySigner_read(ser_ref);
20594         return (uint64_t)ret_conv;
20595 }
20596
20597 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
20598         LDKKeysManager this_obj_conv;
20599         this_obj_conv.inner = (void*)(this_obj & (~1));
20600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20602         KeysManager_free(this_obj_conv);
20603 }
20604
20605 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
20606         unsigned char seed_arr[32];
20607         CHECK(seed->arr_len == 32);
20608         memcpy(seed_arr, seed->elems, 32);
20609         unsigned char (*seed_ref)[32] = &seed_arr;
20610         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20611         uint64_t ret_ref = 0;
20612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20615         ret_ref = (uint64_t)ret_var.inner;
20616         if (ret_var.is_owned) {
20617                 ret_ref |= 1;
20618         }
20619         return ret_ref;
20620 }
20621
20622 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) {
20623         LDKKeysManager this_arg_conv;
20624         this_arg_conv.inner = (void*)(this_arg & (~1));
20625         this_arg_conv.is_owned = false;
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20627         unsigned char params_arr[32];
20628         CHECK(params->arr_len == 32);
20629         memcpy(params_arr, params->elems, 32);
20630         unsigned char (*params_ref)[32] = &params_arr;
20631         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20632         uint64_t ret_ref = 0;
20633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20636         ret_ref = (uint64_t)ret_var.inner;
20637         if (ret_var.is_owned) {
20638                 ret_ref |= 1;
20639         }
20640         return ret_ref;
20641 }
20642
20643 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) {
20644         LDKKeysManager this_arg_conv;
20645         this_arg_conv.inner = (void*)(this_arg & (~1));
20646         this_arg_conv.is_owned = false;
20647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20648         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20649         descriptors_constr.datalen = descriptors->arr_len;
20650         if (descriptors_constr.datalen > 0)
20651                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20652         else
20653                 descriptors_constr.data = NULL;
20654         uint32_t* descriptors_vals = descriptors->elems;
20655         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20656                 uint32_t descriptors_conv_27 = descriptors_vals[b];
20657                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
20658                 CHECK_ACCESS(descriptors_conv_27_ptr);
20659                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20660                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
20661                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20662         }
20663         LDKCVec_TxOutZ outputs_constr;
20664         outputs_constr.datalen = outputs->arr_len;
20665         if (outputs_constr.datalen > 0)
20666                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20667         else
20668                 outputs_constr.data = NULL;
20669         uint32_t* outputs_vals = outputs->elems;
20670         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20671                 uint32_t outputs_conv_7 = outputs_vals[h];
20672                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
20673                 CHECK_ACCESS(outputs_conv_7_ptr);
20674                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20675                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
20676                 outputs_constr.data[h] = outputs_conv_7_conv;
20677         }
20678         LDKCVec_u8Z change_destination_script_ref;
20679         change_destination_script_ref.datalen = change_destination_script->arr_len;
20680         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20681         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen);
20682         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20683         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20684         return (uint64_t)ret_conv;
20685 }
20686
20687 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
20688         LDKKeysManager this_arg_conv;
20689         this_arg_conv.inner = (void*)(this_arg & (~1));
20690         this_arg_conv.is_owned = false;
20691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20692         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20693         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20694         return (uint64_t)ret_ret;
20695 }
20696
20697 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
20698         LDKChannelManager this_obj_conv;
20699         this_obj_conv.inner = (void*)(this_obj & (~1));
20700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20702         ChannelManager_free(this_obj_conv);
20703 }
20704
20705 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
20706         LDKChainParameters this_obj_conv;
20707         this_obj_conv.inner = (void*)(this_obj & (~1));
20708         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20710         ChainParameters_free(this_obj_conv);
20711 }
20712
20713 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
20714         LDKChainParameters this_ptr_conv;
20715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20716         this_ptr_conv.is_owned = false;
20717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20718         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
20719         return ret_conv;
20720 }
20721
20722 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
20723         LDKChainParameters this_ptr_conv;
20724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20725         this_ptr_conv.is_owned = false;
20726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20727         LDKNetwork val_conv = LDKNetwork_from_js(val);
20728         ChainParameters_set_network(&this_ptr_conv, val_conv);
20729 }
20730
20731 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
20732         LDKChainParameters this_ptr_conv;
20733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20734         this_ptr_conv.is_owned = false;
20735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20736         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20737         uint64_t ret_ref = 0;
20738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20741         ret_ref = (uint64_t)ret_var.inner;
20742         if (ret_var.is_owned) {
20743                 ret_ref |= 1;
20744         }
20745         return ret_ref;
20746 }
20747
20748 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
20749         LDKChainParameters this_ptr_conv;
20750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20751         this_ptr_conv.is_owned = false;
20752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20753         LDKBestBlock val_conv;
20754         val_conv.inner = (void*)(val & (~1));
20755         val_conv.is_owned = (val & 1) || (val == 0);
20756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20757         val_conv = BestBlock_clone(&val_conv);
20758         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20759 }
20760
20761 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
20762         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
20763         LDKBestBlock best_block_arg_conv;
20764         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20765         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20766         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
20767         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20768         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20769         uint64_t ret_ref = 0;
20770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20773         ret_ref = (uint64_t)ret_var.inner;
20774         if (ret_var.is_owned) {
20775                 ret_ref |= 1;
20776         }
20777         return ret_ref;
20778 }
20779
20780 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
20781         LDKChainParameters ret_var = ChainParameters_clone(arg);
20782 uint64_t ret_ref = 0;
20783 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20784 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
20787 if (ret_var.is_owned) {
20788         ret_ref |= 1;
20789 }
20790         return ret_ref;
20791 }
20792 int64_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
20793         LDKChainParameters arg_conv;
20794         arg_conv.inner = (void*)(arg & (~1));
20795         arg_conv.is_owned = false;
20796         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20797         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
20798         return ret_val;
20799 }
20800
20801 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
20802         LDKChainParameters orig_conv;
20803         orig_conv.inner = (void*)(orig & (~1));
20804         orig_conv.is_owned = false;
20805         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20806         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20807         uint64_t ret_ref = 0;
20808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20811         ret_ref = (uint64_t)ret_var.inner;
20812         if (ret_var.is_owned) {
20813                 ret_ref |= 1;
20814         }
20815         return ret_ref;
20816 }
20817
20818 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
20819         LDKCounterpartyForwardingInfo this_obj_conv;
20820         this_obj_conv.inner = (void*)(this_obj & (~1));
20821         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20823         CounterpartyForwardingInfo_free(this_obj_conv);
20824 }
20825
20826 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
20827         LDKCounterpartyForwardingInfo this_ptr_conv;
20828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20829         this_ptr_conv.is_owned = false;
20830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20831         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20832         return ret_val;
20833 }
20834
20835 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
20836         LDKCounterpartyForwardingInfo this_ptr_conv;
20837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20838         this_ptr_conv.is_owned = false;
20839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20840         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20841 }
20842
20843 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
20844         LDKCounterpartyForwardingInfo this_ptr_conv;
20845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20846         this_ptr_conv.is_owned = false;
20847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20848         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20849         return ret_val;
20850 }
20851
20852 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
20853         LDKCounterpartyForwardingInfo this_ptr_conv;
20854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20855         this_ptr_conv.is_owned = false;
20856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20857         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20858 }
20859
20860 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20861         LDKCounterpartyForwardingInfo this_ptr_conv;
20862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20863         this_ptr_conv.is_owned = false;
20864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20865         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20866         return ret_val;
20867 }
20868
20869 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20870         LDKCounterpartyForwardingInfo this_ptr_conv;
20871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20872         this_ptr_conv.is_owned = false;
20873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20874         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20875 }
20876
20877 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) {
20878         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
20879         uint64_t ret_ref = 0;
20880         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20881         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20883         ret_ref = (uint64_t)ret_var.inner;
20884         if (ret_var.is_owned) {
20885                 ret_ref |= 1;
20886         }
20887         return ret_ref;
20888 }
20889
20890 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
20891         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
20892 uint64_t ret_ref = 0;
20893 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20894 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
20897 if (ret_var.is_owned) {
20898         ret_ref |= 1;
20899 }
20900         return ret_ref;
20901 }
20902 int64_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
20903         LDKCounterpartyForwardingInfo arg_conv;
20904         arg_conv.inner = (void*)(arg & (~1));
20905         arg_conv.is_owned = false;
20906         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20907         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
20908         return ret_val;
20909 }
20910
20911 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
20912         LDKCounterpartyForwardingInfo orig_conv;
20913         orig_conv.inner = (void*)(orig & (~1));
20914         orig_conv.is_owned = false;
20915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20916         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
20917         uint64_t ret_ref = 0;
20918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20921         ret_ref = (uint64_t)ret_var.inner;
20922         if (ret_var.is_owned) {
20923                 ret_ref |= 1;
20924         }
20925         return ret_ref;
20926 }
20927
20928 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
20929         LDKChannelCounterparty this_obj_conv;
20930         this_obj_conv.inner = (void*)(this_obj & (~1));
20931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20933         ChannelCounterparty_free(this_obj_conv);
20934 }
20935
20936 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
20937         LDKChannelCounterparty this_ptr_conv;
20938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20939         this_ptr_conv.is_owned = false;
20940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20941         int8_tArray ret_arr = init_int8_tArray(33);
20942         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
20943         return ret_arr;
20944 }
20945
20946 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
20947         LDKChannelCounterparty this_ptr_conv;
20948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20949         this_ptr_conv.is_owned = false;
20950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20951         LDKPublicKey val_ref;
20952         CHECK(val->arr_len == 33);
20953         memcpy(val_ref.compressed_form, val->elems, 33);
20954         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
20955 }
20956
20957 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
20958         LDKChannelCounterparty this_ptr_conv;
20959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20960         this_ptr_conv.is_owned = false;
20961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20962         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
20963         uint64_t ret_ref = 0;
20964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20967         ret_ref = (uint64_t)ret_var.inner;
20968         if (ret_var.is_owned) {
20969                 ret_ref |= 1;
20970         }
20971         return ret_ref;
20972 }
20973
20974 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
20975         LDKChannelCounterparty this_ptr_conv;
20976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20977         this_ptr_conv.is_owned = false;
20978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20979         LDKInitFeatures val_conv;
20980         val_conv.inner = (void*)(val & (~1));
20981         val_conv.is_owned = (val & 1) || (val == 0);
20982         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20983         val_conv = InitFeatures_clone(&val_conv);
20984         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
20985 }
20986
20987 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
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         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
20993         return ret_val;
20994 }
20995
20996 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
20997         LDKChannelCounterparty this_ptr_conv;
20998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20999         this_ptr_conv.is_owned = false;
21000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21001         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
21002 }
21003
21004 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
21005         LDKChannelCounterparty this_ptr_conv;
21006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21007         this_ptr_conv.is_owned = false;
21008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21009         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
21010         uint64_t ret_ref = 0;
21011         if ((uint64_t)ret_var.inner > 4096) {
21012                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21013                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21015                 ret_ref = (uint64_t)ret_var.inner;
21016                 if (ret_var.is_owned) {
21017                         ret_ref |= 1;
21018                 }
21019         }
21020         return ret_ref;
21021 }
21022
21023 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
21024         LDKChannelCounterparty this_ptr_conv;
21025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21026         this_ptr_conv.is_owned = false;
21027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21028         LDKCounterpartyForwardingInfo val_conv;
21029         val_conv.inner = (void*)(val & (~1));
21030         val_conv.is_owned = (val & 1) || (val == 0);
21031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21032         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
21033         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
21034 }
21035
21036 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) {
21037         LDKPublicKey node_id_arg_ref;
21038         CHECK(node_id_arg->arr_len == 33);
21039         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33);
21040         LDKInitFeatures features_arg_conv;
21041         features_arg_conv.inner = (void*)(features_arg & (~1));
21042         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21043         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
21044         features_arg_conv = InitFeatures_clone(&features_arg_conv);
21045         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
21046         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
21047         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
21048         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
21049         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
21050         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
21051         uint64_t ret_ref = 0;
21052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21055         ret_ref = (uint64_t)ret_var.inner;
21056         if (ret_var.is_owned) {
21057                 ret_ref |= 1;
21058         }
21059         return ret_ref;
21060 }
21061
21062 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
21063         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
21064 uint64_t ret_ref = 0;
21065 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21066 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
21069 if (ret_var.is_owned) {
21070         ret_ref |= 1;
21071 }
21072         return ret_ref;
21073 }
21074 int64_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
21075         LDKChannelCounterparty arg_conv;
21076         arg_conv.inner = (void*)(arg & (~1));
21077         arg_conv.is_owned = false;
21078         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21079         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
21080         return ret_val;
21081 }
21082
21083 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
21084         LDKChannelCounterparty orig_conv;
21085         orig_conv.inner = (void*)(orig & (~1));
21086         orig_conv.is_owned = false;
21087         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21088         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
21089         uint64_t ret_ref = 0;
21090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21093         ret_ref = (uint64_t)ret_var.inner;
21094         if (ret_var.is_owned) {
21095                 ret_ref |= 1;
21096         }
21097         return ret_ref;
21098 }
21099
21100 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
21101         LDKChannelDetails this_obj_conv;
21102         this_obj_conv.inner = (void*)(this_obj & (~1));
21103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21105         ChannelDetails_free(this_obj_conv);
21106 }
21107
21108 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
21109         LDKChannelDetails this_ptr_conv;
21110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21111         this_ptr_conv.is_owned = false;
21112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21113         int8_tArray ret_arr = init_int8_tArray(32);
21114         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
21115         return ret_arr;
21116 }
21117
21118 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
21119         LDKChannelDetails this_ptr_conv;
21120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21121         this_ptr_conv.is_owned = false;
21122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21123         LDKThirtyTwoBytes val_ref;
21124         CHECK(val->arr_len == 32);
21125         memcpy(val_ref.data, val->elems, 32);
21126         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
21127 }
21128
21129 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
21130         LDKChannelDetails this_ptr_conv;
21131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21132         this_ptr_conv.is_owned = false;
21133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21134         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
21135         uint64_t ret_ref = 0;
21136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21139         ret_ref = (uint64_t)ret_var.inner;
21140         if (ret_var.is_owned) {
21141                 ret_ref |= 1;
21142         }
21143         return ret_ref;
21144 }
21145
21146 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
21147         LDKChannelDetails this_ptr_conv;
21148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21149         this_ptr_conv.is_owned = false;
21150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21151         LDKChannelCounterparty val_conv;
21152         val_conv.inner = (void*)(val & (~1));
21153         val_conv.is_owned = (val & 1) || (val == 0);
21154         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21155         val_conv = ChannelCounterparty_clone(&val_conv);
21156         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
21157 }
21158
21159 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
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         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
21165         uint64_t ret_ref = 0;
21166         if ((uint64_t)ret_var.inner > 4096) {
21167                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21168                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21170                 ret_ref = (uint64_t)ret_var.inner;
21171                 if (ret_var.is_owned) {
21172                         ret_ref |= 1;
21173                 }
21174         }
21175         return ret_ref;
21176 }
21177
21178 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
21179         LDKChannelDetails this_ptr_conv;
21180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21181         this_ptr_conv.is_owned = false;
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21183         LDKOutPoint val_conv;
21184         val_conv.inner = (void*)(val & (~1));
21185         val_conv.is_owned = (val & 1) || (val == 0);
21186         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21187         val_conv = OutPoint_clone(&val_conv);
21188         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
21189 }
21190
21191 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21197         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
21198         uint64_t ret_ref = (uint64_t)ret_copy;
21199         return ret_ref;
21200 }
21201
21202 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
21203         LDKChannelDetails this_ptr_conv;
21204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21205         this_ptr_conv.is_owned = false;
21206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21207         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21208         CHECK_ACCESS(val_ptr);
21209         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21210         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
21211         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
21212 }
21213
21214 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
21215         LDKChannelDetails this_ptr_conv;
21216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21217         this_ptr_conv.is_owned = false;
21218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21219         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
21220         return ret_val;
21221 }
21222
21223 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
21224         LDKChannelDetails this_ptr_conv;
21225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21226         this_ptr_conv.is_owned = false;
21227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21228         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
21229 }
21230
21231 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21232         LDKChannelDetails this_ptr_conv;
21233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21234         this_ptr_conv.is_owned = false;
21235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21236         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21237         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
21238         uint64_t ret_ref = (uint64_t)ret_copy;
21239         return ret_ref;
21240 }
21241
21242 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
21243         LDKChannelDetails this_ptr_conv;
21244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21245         this_ptr_conv.is_owned = false;
21246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21247         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21248         CHECK_ACCESS(val_ptr);
21249         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21250         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
21251         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
21252 }
21253
21254 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
21255         LDKChannelDetails this_ptr_conv;
21256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21257         this_ptr_conv.is_owned = false;
21258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21259         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
21260         return ret_val;
21261 }
21262
21263 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
21264         LDKChannelDetails this_ptr_conv;
21265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21266         this_ptr_conv.is_owned = false;
21267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21268         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
21269 }
21270
21271 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
21272         LDKChannelDetails this_ptr_conv;
21273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21274         this_ptr_conv.is_owned = false;
21275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21276         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
21277         return ret_val;
21278 }
21279
21280 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
21281         LDKChannelDetails this_ptr_conv;
21282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21283         this_ptr_conv.is_owned = false;
21284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21285         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
21286 }
21287
21288 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
21289         LDKChannelDetails this_ptr_conv;
21290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21291         this_ptr_conv.is_owned = false;
21292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21293         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
21294         return ret_val;
21295 }
21296
21297 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21298         LDKChannelDetails this_ptr_conv;
21299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21300         this_ptr_conv.is_owned = false;
21301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21302         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
21303 }
21304
21305 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
21306         LDKChannelDetails this_ptr_conv;
21307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21308         this_ptr_conv.is_owned = false;
21309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21310         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
21311         return ret_val;
21312 }
21313
21314 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21315         LDKChannelDetails this_ptr_conv;
21316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21317         this_ptr_conv.is_owned = false;
21318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21319         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
21320 }
21321
21322 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
21323         LDKChannelDetails this_ptr_conv;
21324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21325         this_ptr_conv.is_owned = false;
21326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21327         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21328         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
21329         uint64_t ret_ref = (uint64_t)ret_copy;
21330         return ret_ref;
21331 }
21332
21333 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
21334         LDKChannelDetails this_ptr_conv;
21335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21336         this_ptr_conv.is_owned = false;
21337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21338         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21339         CHECK_ACCESS(val_ptr);
21340         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
21341         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
21342         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
21343 }
21344
21345 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
21346         LDKChannelDetails this_ptr_conv;
21347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21348         this_ptr_conv.is_owned = false;
21349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21350         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21351         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
21352         uint64_t ret_ref = (uint64_t)ret_copy;
21353         return ret_ref;
21354 }
21355
21356 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) {
21357         LDKChannelDetails this_ptr_conv;
21358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21359         this_ptr_conv.is_owned = false;
21360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21361         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21362         CHECK_ACCESS(val_ptr);
21363         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
21364         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
21365         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
21366 }
21367
21368 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
21369         LDKChannelDetails this_ptr_conv;
21370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21371         this_ptr_conv.is_owned = false;
21372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21373         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
21374         return ret_val;
21375 }
21376
21377 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
21378         LDKChannelDetails this_ptr_conv;
21379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21380         this_ptr_conv.is_owned = false;
21381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21382         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
21383 }
21384
21385 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
21386         LDKChannelDetails this_ptr_conv;
21387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21388         this_ptr_conv.is_owned = false;
21389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21390         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21391         return ret_val;
21392 }
21393
21394 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
21395         LDKChannelDetails this_ptr_conv;
21396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21397         this_ptr_conv.is_owned = false;
21398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21399         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21400 }
21401
21402 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
21403         LDKChannelDetails this_ptr_conv;
21404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21405         this_ptr_conv.is_owned = false;
21406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21407         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21408         return ret_val;
21409 }
21410
21411 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
21412         LDKChannelDetails this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21416         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21417 }
21418
21419 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
21420         LDKChannelDetails this_ptr_conv;
21421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21422         this_ptr_conv.is_owned = false;
21423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21424         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21425         return ret_val;
21426 }
21427
21428 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
21429         LDKChannelDetails this_ptr_conv;
21430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21431         this_ptr_conv.is_owned = false;
21432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21433         ChannelDetails_set_is_public(&this_ptr_conv, val);
21434 }
21435
21436 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) {
21437         LDKThirtyTwoBytes channel_id_arg_ref;
21438         CHECK(channel_id_arg->arr_len == 32);
21439         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
21440         LDKChannelCounterparty counterparty_arg_conv;
21441         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21442         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21443         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
21444         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21445         LDKOutPoint funding_txo_arg_conv;
21446         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21447         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21448         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
21449         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21450         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
21451         CHECK_ACCESS(short_channel_id_arg_ptr);
21452         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21453         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
21454         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
21455         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21456         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21457         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
21458         CHECK_ACCESS(confirmations_required_arg_ptr);
21459         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21460         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
21461         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
21462         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21463         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21464         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
21465         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);
21466         uint64_t ret_ref = 0;
21467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21470         ret_ref = (uint64_t)ret_var.inner;
21471         if (ret_var.is_owned) {
21472                 ret_ref |= 1;
21473         }
21474         return ret_ref;
21475 }
21476
21477 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
21478         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
21479 uint64_t ret_ref = 0;
21480 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21481 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
21484 if (ret_var.is_owned) {
21485         ret_ref |= 1;
21486 }
21487         return ret_ref;
21488 }
21489 int64_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
21490         LDKChannelDetails arg_conv;
21491         arg_conv.inner = (void*)(arg & (~1));
21492         arg_conv.is_owned = false;
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21494         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
21495         return ret_val;
21496 }
21497
21498 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
21499         LDKChannelDetails orig_conv;
21500         orig_conv.inner = (void*)(orig & (~1));
21501         orig_conv.is_owned = false;
21502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21503         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21504         uint64_t ret_ref = 0;
21505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21508         ret_ref = (uint64_t)ret_var.inner;
21509         if (ret_var.is_owned) {
21510                 ret_ref |= 1;
21511         }
21512         return ret_ref;
21513 }
21514
21515 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
21516         if ((this_ptr & 1) != 0) return;
21517         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21518         CHECK_ACCESS(this_ptr_ptr);
21519         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21520         FREE((void*)this_ptr);
21521         PaymentSendFailure_free(this_ptr_conv);
21522 }
21523
21524 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
21525         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21526         *ret_copy = PaymentSendFailure_clone(arg);
21527 uint64_t ret_ref = (uint64_t)ret_copy;
21528         return ret_ref;
21529 }
21530 int64_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
21531         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
21532         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
21533         return ret_val;
21534 }
21535
21536 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
21537         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21538         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21539         *ret_copy = PaymentSendFailure_clone(orig_conv);
21540         uint64_t ret_ref = (uint64_t)ret_copy;
21541         return ret_ref;
21542 }
21543
21544 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
21545         void* a_ptr = (void*)(((uint64_t)a) & ~1);
21546         CHECK_ACCESS(a_ptr);
21547         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21548         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
21549         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21550         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21551         uint64_t ret_ref = (uint64_t)ret_copy;
21552         return ret_ref;
21553 }
21554
21555 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
21556         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21557         a_constr.datalen = a->arr_len;
21558         if (a_constr.datalen > 0)
21559                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21560         else
21561                 a_constr.data = NULL;
21562         uint32_t* a_vals = a->elems;
21563         for (size_t w = 0; w < a_constr.datalen; w++) {
21564                 uint32_t a_conv_22 = a_vals[w];
21565                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
21566                 CHECK_ACCESS(a_conv_22_ptr);
21567                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21568                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
21569                 a_constr.data[w] = a_conv_22_conv;
21570         }
21571         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21572         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21573         uint64_t ret_ref = (uint64_t)ret_copy;
21574         return ret_ref;
21575 }
21576
21577 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
21578         LDKCVec_APIErrorZ a_constr;
21579         a_constr.datalen = a->arr_len;
21580         if (a_constr.datalen > 0)
21581                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21582         else
21583                 a_constr.data = NULL;
21584         uint32_t* a_vals = a->elems;
21585         for (size_t k = 0; k < a_constr.datalen; k++) {
21586                 uint32_t a_conv_10 = a_vals[k];
21587                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
21588                 CHECK_ACCESS(a_conv_10_ptr);
21589                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21590                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
21591                 a_constr.data[k] = a_conv_10_conv;
21592         }
21593         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21594         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21595         uint64_t ret_ref = (uint64_t)ret_copy;
21596         return ret_ref;
21597 }
21598
21599 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) {
21600         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21601         results_constr.datalen = results->arr_len;
21602         if (results_constr.datalen > 0)
21603                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21604         else
21605                 results_constr.data = NULL;
21606         uint32_t* results_vals = results->elems;
21607         for (size_t w = 0; w < results_constr.datalen; w++) {
21608                 uint32_t results_conv_22 = results_vals[w];
21609                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
21610                 CHECK_ACCESS(results_conv_22_ptr);
21611                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21612                 results_constr.data[w] = results_conv_22_conv;
21613         }
21614         LDKRouteParameters failed_paths_retry_conv;
21615         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21616         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21617         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
21618         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21619         LDKThirtyTwoBytes payment_id_ref;
21620         CHECK(payment_id->arr_len == 32);
21621         memcpy(payment_id_ref.data, payment_id->elems, 32);
21622         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21623         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21624         uint64_t ret_ref = (uint64_t)ret_copy;
21625         return ret_ref;
21626 }
21627
21628 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) {
21629         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
21630         CHECK_ACCESS(fee_est_ptr);
21631         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21632         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21633         CHECK_ACCESS(chain_monitor_ptr);
21634         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21635         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21636         CHECK_ACCESS(tx_broadcaster_ptr);
21637         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21638         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21639         CHECK_ACCESS(logger_ptr);
21640         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21641         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21642         CHECK_ACCESS(keys_manager_ptr);
21643         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21644         LDKUserConfig config_conv;
21645         config_conv.inner = (void*)(config & (~1));
21646         config_conv.is_owned = (config & 1) || (config == 0);
21647         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
21648         config_conv = UserConfig_clone(&config_conv);
21649         LDKChainParameters params_conv;
21650         params_conv.inner = (void*)(params & (~1));
21651         params_conv.is_owned = (params & 1) || (params == 0);
21652         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
21653         params_conv = ChainParameters_clone(&params_conv);
21654         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21655         uint64_t ret_ref = 0;
21656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21659         ret_ref = (uint64_t)ret_var.inner;
21660         if (ret_var.is_owned) {
21661                 ret_ref |= 1;
21662         }
21663         return ret_ref;
21664 }
21665
21666 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
21667         LDKChannelManager this_arg_conv;
21668         this_arg_conv.inner = (void*)(this_arg & (~1));
21669         this_arg_conv.is_owned = false;
21670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21671         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21672         uint64_t ret_ref = 0;
21673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21676         ret_ref = (uint64_t)ret_var.inner;
21677         if (ret_var.is_owned) {
21678                 ret_ref |= 1;
21679         }
21680         return ret_ref;
21681 }
21682
21683 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) {
21684         LDKChannelManager this_arg_conv;
21685         this_arg_conv.inner = (void*)(this_arg & (~1));
21686         this_arg_conv.is_owned = false;
21687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21688         LDKPublicKey their_network_key_ref;
21689         CHECK(their_network_key->arr_len == 33);
21690         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33);
21691         LDKUserConfig override_config_conv;
21692         override_config_conv.inner = (void*)(override_config & (~1));
21693         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21694         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
21695         override_config_conv = UserConfig_clone(&override_config_conv);
21696         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21697         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21698         return (uint64_t)ret_conv;
21699 }
21700
21701 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
21702         LDKChannelManager this_arg_conv;
21703         this_arg_conv.inner = (void*)(this_arg & (~1));
21704         this_arg_conv.is_owned = false;
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21706         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21707         uint32_tArray ret_arr = NULL;
21708         ret_arr = init_uint32_tArray(ret_var.datalen);
21709         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21710         for (size_t q = 0; q < ret_var.datalen; q++) {
21711                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21712                 uint64_t ret_conv_16_ref = 0;
21713                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21714                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21715                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21716                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21717                 if (ret_conv_16_var.is_owned) {
21718                         ret_conv_16_ref |= 1;
21719                 }
21720                 ret_arr_ptr[q] = ret_conv_16_ref;
21721         }
21722         
21723         FREE(ret_var.data);
21724         return ret_arr;
21725 }
21726
21727 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
21728         LDKChannelManager this_arg_conv;
21729         this_arg_conv.inner = (void*)(this_arg & (~1));
21730         this_arg_conv.is_owned = false;
21731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21732         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21733         uint32_tArray ret_arr = NULL;
21734         ret_arr = init_uint32_tArray(ret_var.datalen);
21735         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21736         for (size_t q = 0; q < ret_var.datalen; q++) {
21737                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21738                 uint64_t ret_conv_16_ref = 0;
21739                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21740                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21742                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21743                 if (ret_conv_16_var.is_owned) {
21744                         ret_conv_16_ref |= 1;
21745                 }
21746                 ret_arr_ptr[q] = ret_conv_16_ref;
21747         }
21748         
21749         FREE(ret_var.data);
21750         return ret_arr;
21751 }
21752
21753 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21754         LDKChannelManager this_arg_conv;
21755         this_arg_conv.inner = (void*)(this_arg & (~1));
21756         this_arg_conv.is_owned = false;
21757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21758         unsigned char channel_id_arr[32];
21759         CHECK(channel_id->arr_len == 32);
21760         memcpy(channel_id_arr, channel_id->elems, 32);
21761         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21762         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21763         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21764         return (uint64_t)ret_conv;
21765 }
21766
21767 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) {
21768         LDKChannelManager this_arg_conv;
21769         this_arg_conv.inner = (void*)(this_arg & (~1));
21770         this_arg_conv.is_owned = false;
21771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21772         unsigned char channel_id_arr[32];
21773         CHECK(channel_id->arr_len == 32);
21774         memcpy(channel_id_arr, channel_id->elems, 32);
21775         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21776         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21777         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21778         return (uint64_t)ret_conv;
21779 }
21780
21781 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21782         LDKChannelManager this_arg_conv;
21783         this_arg_conv.inner = (void*)(this_arg & (~1));
21784         this_arg_conv.is_owned = false;
21785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21786         unsigned char channel_id_arr[32];
21787         CHECK(channel_id->arr_len == 32);
21788         memcpy(channel_id_arr, channel_id->elems, 32);
21789         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21790         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21791         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21792         return (uint64_t)ret_conv;
21793 }
21794
21795 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
21796         LDKChannelManager this_arg_conv;
21797         this_arg_conv.inner = (void*)(this_arg & (~1));
21798         this_arg_conv.is_owned = false;
21799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21800         ChannelManager_force_close_all_channels(&this_arg_conv);
21801 }
21802
21803 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) {
21804         LDKChannelManager this_arg_conv;
21805         this_arg_conv.inner = (void*)(this_arg & (~1));
21806         this_arg_conv.is_owned = false;
21807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21808         LDKRoute route_conv;
21809         route_conv.inner = (void*)(route & (~1));
21810         route_conv.is_owned = false;
21811         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21812         LDKThirtyTwoBytes payment_hash_ref;
21813         CHECK(payment_hash->arr_len == 32);
21814         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
21815         LDKThirtyTwoBytes payment_secret_ref;
21816         CHECK(payment_secret->arr_len == 32);
21817         memcpy(payment_secret_ref.data, payment_secret->elems, 32);
21818         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21819         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21820         return (uint64_t)ret_conv;
21821 }
21822
21823 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
21824         LDKChannelManager this_arg_conv;
21825         this_arg_conv.inner = (void*)(this_arg & (~1));
21826         this_arg_conv.is_owned = false;
21827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21828         LDKRoute route_conv;
21829         route_conv.inner = (void*)(route & (~1));
21830         route_conv.is_owned = false;
21831         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21832         LDKThirtyTwoBytes payment_id_ref;
21833         CHECK(payment_id->arr_len == 32);
21834         memcpy(payment_id_ref.data, payment_id->elems, 32);
21835         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21836         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21837         return (uint64_t)ret_conv;
21838 }
21839
21840 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
21841         LDKChannelManager this_arg_conv;
21842         this_arg_conv.inner = (void*)(this_arg & (~1));
21843         this_arg_conv.is_owned = false;
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21845         LDKThirtyTwoBytes payment_id_ref;
21846         CHECK(payment_id->arr_len == 32);
21847         memcpy(payment_id_ref.data, payment_id->elems, 32);
21848         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
21849 }
21850
21851 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) {
21852         LDKChannelManager this_arg_conv;
21853         this_arg_conv.inner = (void*)(this_arg & (~1));
21854         this_arg_conv.is_owned = false;
21855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21856         LDKRoute route_conv;
21857         route_conv.inner = (void*)(route & (~1));
21858         route_conv.is_owned = false;
21859         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21860         LDKThirtyTwoBytes payment_preimage_ref;
21861         CHECK(payment_preimage->arr_len == 32);
21862         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32);
21863         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21864         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21865         return (uint64_t)ret_conv;
21866 }
21867
21868 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) {
21869         LDKChannelManager this_arg_conv;
21870         this_arg_conv.inner = (void*)(this_arg & (~1));
21871         this_arg_conv.is_owned = false;
21872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21873         unsigned char temporary_channel_id_arr[32];
21874         CHECK(temporary_channel_id->arr_len == 32);
21875         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32);
21876         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
21877         LDKTransaction funding_transaction_ref;
21878         funding_transaction_ref.datalen = funding_transaction->arr_len;
21879         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
21880         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen);
21881         funding_transaction_ref.data_is_owned = true;
21882         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21883         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
21884         return (uint64_t)ret_conv;
21885 }
21886
21887 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) {
21888         LDKChannelManager this_arg_conv;
21889         this_arg_conv.inner = (void*)(this_arg & (~1));
21890         this_arg_conv.is_owned = false;
21891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21892         LDKThreeBytes rgb_ref;
21893         CHECK(rgb->arr_len == 3);
21894         memcpy(rgb_ref.data, rgb->elems, 3);
21895         LDKThirtyTwoBytes alias_ref;
21896         CHECK(alias->arr_len == 32);
21897         memcpy(alias_ref.data, alias->elems, 32);
21898         LDKCVec_NetAddressZ addresses_constr;
21899         addresses_constr.datalen = addresses->arr_len;
21900         if (addresses_constr.datalen > 0)
21901                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21902         else
21903                 addresses_constr.data = NULL;
21904         uint32_t* addresses_vals = addresses->elems;
21905         for (size_t m = 0; m < addresses_constr.datalen; m++) {
21906                 uint32_t addresses_conv_12 = addresses_vals[m];
21907                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
21908                 CHECK_ACCESS(addresses_conv_12_ptr);
21909                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
21910                 addresses_constr.data[m] = addresses_conv_12_conv;
21911         }
21912         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
21913 }
21914
21915 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
21916         LDKChannelManager this_arg_conv;
21917         this_arg_conv.inner = (void*)(this_arg & (~1));
21918         this_arg_conv.is_owned = false;
21919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21920         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
21921 }
21922
21923 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
21924         LDKChannelManager this_arg_conv;
21925         this_arg_conv.inner = (void*)(this_arg & (~1));
21926         this_arg_conv.is_owned = false;
21927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21928         ChannelManager_timer_tick_occurred(&this_arg_conv);
21929 }
21930
21931 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
21932         LDKChannelManager this_arg_conv;
21933         this_arg_conv.inner = (void*)(this_arg & (~1));
21934         this_arg_conv.is_owned = false;
21935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21936         unsigned char payment_hash_arr[32];
21937         CHECK(payment_hash->arr_len == 32);
21938         memcpy(payment_hash_arr, payment_hash->elems, 32);
21939         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
21940         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
21941         return ret_val;
21942 }
21943
21944 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
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         LDKThirtyTwoBytes payment_preimage_ref;
21950         CHECK(payment_preimage->arr_len == 32);
21951         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32);
21952         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
21953         return ret_val;
21954 }
21955
21956 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
21957         LDKChannelManager this_arg_conv;
21958         this_arg_conv.inner = (void*)(this_arg & (~1));
21959         this_arg_conv.is_owned = false;
21960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21961         int8_tArray ret_arr = init_int8_tArray(33);
21962         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
21963         return ret_arr;
21964 }
21965
21966 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) {
21967         LDKChannelManager this_arg_conv;
21968         this_arg_conv.inner = (void*)(this_arg & (~1));
21969         this_arg_conv.is_owned = false;
21970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21971         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21972         CHECK_ACCESS(min_value_msat_ptr);
21973         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21974         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21975         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21976         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
21977         return (uint64_t)ret_conv;
21978 }
21979
21980 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) {
21981         LDKChannelManager this_arg_conv;
21982         this_arg_conv.inner = (void*)(this_arg & (~1));
21983         this_arg_conv.is_owned = false;
21984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21985         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21986         CHECK_ACCESS(min_value_msat_ptr);
21987         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21988         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21989         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21990         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
21991         return (uint64_t)ret_conv;
21992 }
21993
21994 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) {
21995         LDKChannelManager this_arg_conv;
21996         this_arg_conv.inner = (void*)(this_arg & (~1));
21997         this_arg_conv.is_owned = false;
21998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21999         LDKThirtyTwoBytes payment_hash_ref;
22000         CHECK(payment_hash->arr_len == 32);
22001         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
22002         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22003         CHECK_ACCESS(min_value_msat_ptr);
22004         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22005         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22006         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22007         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22008         return (uint64_t)ret_conv;
22009 }
22010
22011 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) {
22012         LDKChannelManager this_arg_conv;
22013         this_arg_conv.inner = (void*)(this_arg & (~1));
22014         this_arg_conv.is_owned = false;
22015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22016         LDKThirtyTwoBytes payment_hash_ref;
22017         CHECK(payment_hash->arr_len == 32);
22018         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
22019         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22020         CHECK_ACCESS(min_value_msat_ptr);
22021         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22022         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22023         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22024         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22025         return (uint64_t)ret_conv;
22026 }
22027
22028 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) {
22029         LDKChannelManager this_arg_conv;
22030         this_arg_conv.inner = (void*)(this_arg & (~1));
22031         this_arg_conv.is_owned = false;
22032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22033         LDKThirtyTwoBytes payment_hash_ref;
22034         CHECK(payment_hash->arr_len == 32);
22035         memcpy(payment_hash_ref.data, payment_hash->elems, 32);
22036         LDKThirtyTwoBytes payment_secret_ref;
22037         CHECK(payment_secret->arr_len == 32);
22038         memcpy(payment_secret_ref.data, payment_secret->elems, 32);
22039         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22040         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
22041         return (uint64_t)ret_conv;
22042 }
22043
22044 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
22045         LDKChannelManager this_arg_conv;
22046         this_arg_conv.inner = (void*)(this_arg & (~1));
22047         this_arg_conv.is_owned = false;
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22049         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22050         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
22051         return (uint64_t)ret_ret;
22052 }
22053
22054 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
22055         LDKChannelManager this_arg_conv;
22056         this_arg_conv.inner = (void*)(this_arg & (~1));
22057         this_arg_conv.is_owned = false;
22058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22059         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22060         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
22061         return (uint64_t)ret_ret;
22062 }
22063
22064 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
22065         LDKChannelManager this_arg_conv;
22066         this_arg_conv.inner = (void*)(this_arg & (~1));
22067         this_arg_conv.is_owned = false;
22068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22069         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22070         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
22071         return (uint64_t)ret_ret;
22072 }
22073
22074 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
22075         LDKChannelManager this_arg_conv;
22076         this_arg_conv.inner = (void*)(this_arg & (~1));
22077         this_arg_conv.is_owned = false;
22078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22079         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22080         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
22081         return (uint64_t)ret_ret;
22082 }
22083
22084 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
22085         LDKChannelManager this_arg_conv;
22086         this_arg_conv.inner = (void*)(this_arg & (~1));
22087         this_arg_conv.is_owned = false;
22088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22089         ChannelManager_await_persistable_update(&this_arg_conv);
22090 }
22091
22092 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
22093         LDKChannelManager this_arg_conv;
22094         this_arg_conv.inner = (void*)(this_arg & (~1));
22095         this_arg_conv.is_owned = false;
22096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22097         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
22098         uint64_t ret_ref = 0;
22099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22102         ret_ref = (uint64_t)ret_var.inner;
22103         if (ret_var.is_owned) {
22104                 ret_ref |= 1;
22105         }
22106         return ret_ref;
22107 }
22108
22109 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
22110         LDKChannelManager this_arg_conv;
22111         this_arg_conv.inner = (void*)(this_arg & (~1));
22112         this_arg_conv.is_owned = false;
22113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22114         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22115         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
22116         return (uint64_t)ret_ret;
22117 }
22118
22119 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
22120         LDKChannelManager obj_conv;
22121         obj_conv.inner = (void*)(obj & (~1));
22122         obj_conv.is_owned = false;
22123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22124         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
22125         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
22126         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22127         CVec_u8Z_free(ret_var);
22128         return ret_arr;
22129 }
22130
22131 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
22132         LDKChannelManagerReadArgs this_obj_conv;
22133         this_obj_conv.inner = (void*)(this_obj & (~1));
22134         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22136         ChannelManagerReadArgs_free(this_obj_conv);
22137 }
22138
22139 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
22140         LDKChannelManagerReadArgs this_ptr_conv;
22141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22142         this_ptr_conv.is_owned = false;
22143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22144         // WARNING: This object doesn't live past this scope, needs clone!
22145         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
22146         return ret_ret;
22147 }
22148
22149 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
22150         LDKChannelManagerReadArgs this_ptr_conv;
22151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22152         this_ptr_conv.is_owned = false;
22153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22154         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22155         CHECK_ACCESS(val_ptr);
22156         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
22157         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
22158 }
22159
22160 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
22161         LDKChannelManagerReadArgs this_ptr_conv;
22162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22163         this_ptr_conv.is_owned = false;
22164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22165         // WARNING: This object doesn't live past this scope, needs clone!
22166         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
22167         return ret_ret;
22168 }
22169
22170 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
22171         LDKChannelManagerReadArgs this_ptr_conv;
22172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22173         this_ptr_conv.is_owned = false;
22174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22175         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22176         CHECK_ACCESS(val_ptr);
22177         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
22178         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
22179 }
22180
22181 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
22182         LDKChannelManagerReadArgs this_ptr_conv;
22183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22184         this_ptr_conv.is_owned = false;
22185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22186         // WARNING: This object doesn't live past this scope, needs clone!
22187         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
22188         return ret_ret;
22189 }
22190
22191 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
22192         LDKChannelManagerReadArgs this_ptr_conv;
22193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22194         this_ptr_conv.is_owned = false;
22195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22196         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22197         CHECK_ACCESS(val_ptr);
22198         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
22199         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
22200 }
22201
22202 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
22203         LDKChannelManagerReadArgs this_ptr_conv;
22204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22205         this_ptr_conv.is_owned = false;
22206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22207         // WARNING: This object doesn't live past this scope, needs clone!
22208         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
22209         return ret_ret;
22210 }
22211
22212 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
22213         LDKChannelManagerReadArgs this_ptr_conv;
22214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22215         this_ptr_conv.is_owned = false;
22216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22217         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22218         CHECK_ACCESS(val_ptr);
22219         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
22220         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
22221 }
22222
22223 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
22224         LDKChannelManagerReadArgs this_ptr_conv;
22225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22226         this_ptr_conv.is_owned = false;
22227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22228         // WARNING: This object doesn't live past this scope, needs clone!
22229         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
22230         return ret_ret;
22231 }
22232
22233 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
22234         LDKChannelManagerReadArgs this_ptr_conv;
22235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22236         this_ptr_conv.is_owned = false;
22237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22238         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22239         CHECK_ACCESS(val_ptr);
22240         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
22241         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
22242 }
22243
22244 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
22245         LDKChannelManagerReadArgs this_ptr_conv;
22246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22247         this_ptr_conv.is_owned = false;
22248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22249         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
22250         uint64_t ret_ref = 0;
22251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22254         ret_ref = (uint64_t)ret_var.inner;
22255         if (ret_var.is_owned) {
22256                 ret_ref |= 1;
22257         }
22258         return ret_ref;
22259 }
22260
22261 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
22262         LDKChannelManagerReadArgs this_ptr_conv;
22263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22264         this_ptr_conv.is_owned = false;
22265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22266         LDKUserConfig val_conv;
22267         val_conv.inner = (void*)(val & (~1));
22268         val_conv.is_owned = (val & 1) || (val == 0);
22269         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22270         val_conv = UserConfig_clone(&val_conv);
22271         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
22272 }
22273
22274 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) {
22275         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
22276         CHECK_ACCESS(keys_manager_ptr);
22277         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
22278         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22279         CHECK_ACCESS(fee_estimator_ptr);
22280         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22281         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
22282         CHECK_ACCESS(chain_monitor_ptr);
22283         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
22284         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
22285         CHECK_ACCESS(tx_broadcaster_ptr);
22286         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
22287         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22288         CHECK_ACCESS(logger_ptr);
22289         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22290         LDKUserConfig default_config_conv;
22291         default_config_conv.inner = (void*)(default_config & (~1));
22292         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
22293         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
22294         default_config_conv = UserConfig_clone(&default_config_conv);
22295         LDKCVec_ChannelMonitorZ channel_monitors_constr;
22296         channel_monitors_constr.datalen = channel_monitors->arr_len;
22297         if (channel_monitors_constr.datalen > 0)
22298                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22299         else
22300                 channel_monitors_constr.data = NULL;
22301         uint32_t* channel_monitors_vals = channel_monitors->elems;
22302         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
22303                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
22304                 LDKChannelMonitor channel_monitors_conv_16_conv;
22305                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
22306                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
22307                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
22308                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
22309         }
22310         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);
22311         uint64_t ret_ref = 0;
22312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22315         ret_ref = (uint64_t)ret_var.inner;
22316         if (ret_var.is_owned) {
22317                 ret_ref |= 1;
22318         }
22319         return ret_ref;
22320 }
22321
22322 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
22323         LDKu8slice ser_ref;
22324         ser_ref.datalen = ser->arr_len;
22325         ser_ref.data = ser->elems;
22326         LDKChannelManagerReadArgs arg_conv;
22327         arg_conv.inner = (void*)(arg & (~1));
22328         arg_conv.is_owned = (arg & 1) || (arg == 0);
22329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22330         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
22331         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22332         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
22333         return (uint64_t)ret_conv;
22334 }
22335
22336 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
22337         LDKDecodeError this_obj_conv;
22338         this_obj_conv.inner = (void*)(this_obj & (~1));
22339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22341         DecodeError_free(this_obj_conv);
22342 }
22343
22344 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
22345         LDKDecodeError ret_var = DecodeError_clone(arg);
22346 uint64_t ret_ref = 0;
22347 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22348 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22350 ret_ref = (uint64_t)ret_var.inner;
22351 if (ret_var.is_owned) {
22352         ret_ref |= 1;
22353 }
22354         return ret_ref;
22355 }
22356 int64_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
22357         LDKDecodeError arg_conv;
22358         arg_conv.inner = (void*)(arg & (~1));
22359         arg_conv.is_owned = false;
22360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22361         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
22362         return ret_val;
22363 }
22364
22365 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
22366         LDKDecodeError orig_conv;
22367         orig_conv.inner = (void*)(orig & (~1));
22368         orig_conv.is_owned = false;
22369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22370         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
22371         uint64_t ret_ref = 0;
22372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22375         ret_ref = (uint64_t)ret_var.inner;
22376         if (ret_var.is_owned) {
22377                 ret_ref |= 1;
22378         }
22379         return ret_ref;
22380 }
22381
22382 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
22383         LDKInit this_obj_conv;
22384         this_obj_conv.inner = (void*)(this_obj & (~1));
22385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22387         Init_free(this_obj_conv);
22388 }
22389
22390 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
22391         LDKInit this_ptr_conv;
22392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22393         this_ptr_conv.is_owned = false;
22394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22395         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
22396         uint64_t ret_ref = 0;
22397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22400         ret_ref = (uint64_t)ret_var.inner;
22401         if (ret_var.is_owned) {
22402                 ret_ref |= 1;
22403         }
22404         return ret_ref;
22405 }
22406
22407 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
22408         LDKInit this_ptr_conv;
22409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22410         this_ptr_conv.is_owned = false;
22411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22412         LDKInitFeatures val_conv;
22413         val_conv.inner = (void*)(val & (~1));
22414         val_conv.is_owned = (val & 1) || (val == 0);
22415         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22416         val_conv = InitFeatures_clone(&val_conv);
22417         Init_set_features(&this_ptr_conv, val_conv);
22418 }
22419
22420 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
22421         LDKInitFeatures features_arg_conv;
22422         features_arg_conv.inner = (void*)(features_arg & (~1));
22423         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22424         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
22425         features_arg_conv = InitFeatures_clone(&features_arg_conv);
22426         LDKInit ret_var = Init_new(features_arg_conv);
22427         uint64_t ret_ref = 0;
22428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22431         ret_ref = (uint64_t)ret_var.inner;
22432         if (ret_var.is_owned) {
22433                 ret_ref |= 1;
22434         }
22435         return ret_ref;
22436 }
22437
22438 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
22439         LDKInit ret_var = Init_clone(arg);
22440 uint64_t ret_ref = 0;
22441 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22442 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
22445 if (ret_var.is_owned) {
22446         ret_ref |= 1;
22447 }
22448         return ret_ref;
22449 }
22450 int64_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
22451         LDKInit arg_conv;
22452         arg_conv.inner = (void*)(arg & (~1));
22453         arg_conv.is_owned = false;
22454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22455         int64_t ret_val = Init_clone_ptr(&arg_conv);
22456         return ret_val;
22457 }
22458
22459 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
22460         LDKInit orig_conv;
22461         orig_conv.inner = (void*)(orig & (~1));
22462         orig_conv.is_owned = false;
22463         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22464         LDKInit ret_var = Init_clone(&orig_conv);
22465         uint64_t ret_ref = 0;
22466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22469         ret_ref = (uint64_t)ret_var.inner;
22470         if (ret_var.is_owned) {
22471                 ret_ref |= 1;
22472         }
22473         return ret_ref;
22474 }
22475
22476 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
22477         LDKErrorMessage this_obj_conv;
22478         this_obj_conv.inner = (void*)(this_obj & (~1));
22479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22481         ErrorMessage_free(this_obj_conv);
22482 }
22483
22484 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
22485         LDKErrorMessage this_ptr_conv;
22486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22487         this_ptr_conv.is_owned = false;
22488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22489         int8_tArray ret_arr = init_int8_tArray(32);
22490         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
22491         return ret_arr;
22492 }
22493
22494 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
22495         LDKErrorMessage this_ptr_conv;
22496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22497         this_ptr_conv.is_owned = false;
22498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22499         LDKThirtyTwoBytes val_ref;
22500         CHECK(val->arr_len == 32);
22501         memcpy(val_ref.data, val->elems, 32);
22502         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22503 }
22504
22505 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
22506         LDKErrorMessage this_ptr_conv;
22507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22508         this_ptr_conv.is_owned = false;
22509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22510         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22511         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22512         Str_free(ret_str);
22513         return ret_conv;
22514 }
22515
22516 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
22517         LDKErrorMessage this_ptr_conv;
22518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22519         this_ptr_conv.is_owned = false;
22520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22521         LDKStr val_conv = str_ref_to_owned_c(val);
22522         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22523 }
22524
22525 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
22526         LDKThirtyTwoBytes channel_id_arg_ref;
22527         CHECK(channel_id_arg->arr_len == 32);
22528         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
22529         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
22530         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22531         uint64_t ret_ref = 0;
22532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22535         ret_ref = (uint64_t)ret_var.inner;
22536         if (ret_var.is_owned) {
22537                 ret_ref |= 1;
22538         }
22539         return ret_ref;
22540 }
22541
22542 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
22543         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
22544 uint64_t ret_ref = 0;
22545 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22546 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
22549 if (ret_var.is_owned) {
22550         ret_ref |= 1;
22551 }
22552         return ret_ref;
22553 }
22554 int64_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
22555         LDKErrorMessage arg_conv;
22556         arg_conv.inner = (void*)(arg & (~1));
22557         arg_conv.is_owned = false;
22558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22559         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
22560         return ret_val;
22561 }
22562
22563 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
22564         LDKErrorMessage orig_conv;
22565         orig_conv.inner = (void*)(orig & (~1));
22566         orig_conv.is_owned = false;
22567         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22568         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22569         uint64_t ret_ref = 0;
22570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22573         ret_ref = (uint64_t)ret_var.inner;
22574         if (ret_var.is_owned) {
22575                 ret_ref |= 1;
22576         }
22577         return ret_ref;
22578 }
22579
22580 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
22581         LDKPing this_obj_conv;
22582         this_obj_conv.inner = (void*)(this_obj & (~1));
22583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22585         Ping_free(this_obj_conv);
22586 }
22587
22588 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
22589         LDKPing this_ptr_conv;
22590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22591         this_ptr_conv.is_owned = false;
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22593         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22594         return ret_val;
22595 }
22596
22597 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
22598         LDKPing this_ptr_conv;
22599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22600         this_ptr_conv.is_owned = false;
22601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22602         Ping_set_ponglen(&this_ptr_conv, val);
22603 }
22604
22605 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
22606         LDKPing this_ptr_conv;
22607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22608         this_ptr_conv.is_owned = false;
22609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22610         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22611         return ret_val;
22612 }
22613
22614 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
22615         LDKPing this_ptr_conv;
22616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22617         this_ptr_conv.is_owned = false;
22618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22619         Ping_set_byteslen(&this_ptr_conv, val);
22620 }
22621
22622 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
22623         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22624         uint64_t ret_ref = 0;
22625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22628         ret_ref = (uint64_t)ret_var.inner;
22629         if (ret_var.is_owned) {
22630                 ret_ref |= 1;
22631         }
22632         return ret_ref;
22633 }
22634
22635 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
22636         LDKPing ret_var = Ping_clone(arg);
22637 uint64_t ret_ref = 0;
22638 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22639 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
22642 if (ret_var.is_owned) {
22643         ret_ref |= 1;
22644 }
22645         return ret_ref;
22646 }
22647 int64_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
22648         LDKPing arg_conv;
22649         arg_conv.inner = (void*)(arg & (~1));
22650         arg_conv.is_owned = false;
22651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22652         int64_t ret_val = Ping_clone_ptr(&arg_conv);
22653         return ret_val;
22654 }
22655
22656 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
22657         LDKPing orig_conv;
22658         orig_conv.inner = (void*)(orig & (~1));
22659         orig_conv.is_owned = false;
22660         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22661         LDKPing ret_var = Ping_clone(&orig_conv);
22662         uint64_t ret_ref = 0;
22663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22666         ret_ref = (uint64_t)ret_var.inner;
22667         if (ret_var.is_owned) {
22668                 ret_ref |= 1;
22669         }
22670         return ret_ref;
22671 }
22672
22673 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
22674         LDKPong this_obj_conv;
22675         this_obj_conv.inner = (void*)(this_obj & (~1));
22676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22678         Pong_free(this_obj_conv);
22679 }
22680
22681 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
22682         LDKPong this_ptr_conv;
22683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22684         this_ptr_conv.is_owned = false;
22685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22686         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22687         return ret_val;
22688 }
22689
22690 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
22691         LDKPong this_ptr_conv;
22692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22693         this_ptr_conv.is_owned = false;
22694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22695         Pong_set_byteslen(&this_ptr_conv, val);
22696 }
22697
22698 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
22699         LDKPong ret_var = Pong_new(byteslen_arg);
22700         uint64_t ret_ref = 0;
22701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22704         ret_ref = (uint64_t)ret_var.inner;
22705         if (ret_var.is_owned) {
22706                 ret_ref |= 1;
22707         }
22708         return ret_ref;
22709 }
22710
22711 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
22712         LDKPong ret_var = Pong_clone(arg);
22713 uint64_t ret_ref = 0;
22714 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22715 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
22718 if (ret_var.is_owned) {
22719         ret_ref |= 1;
22720 }
22721         return ret_ref;
22722 }
22723 int64_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
22724         LDKPong arg_conv;
22725         arg_conv.inner = (void*)(arg & (~1));
22726         arg_conv.is_owned = false;
22727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22728         int64_t ret_val = Pong_clone_ptr(&arg_conv);
22729         return ret_val;
22730 }
22731
22732 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
22733         LDKPong orig_conv;
22734         orig_conv.inner = (void*)(orig & (~1));
22735         orig_conv.is_owned = false;
22736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22737         LDKPong ret_var = Pong_clone(&orig_conv);
22738         uint64_t ret_ref = 0;
22739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22742         ret_ref = (uint64_t)ret_var.inner;
22743         if (ret_var.is_owned) {
22744                 ret_ref |= 1;
22745         }
22746         return ret_ref;
22747 }
22748
22749 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
22750         LDKOpenChannel this_obj_conv;
22751         this_obj_conv.inner = (void*)(this_obj & (~1));
22752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22754         OpenChannel_free(this_obj_conv);
22755 }
22756
22757 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
22758         LDKOpenChannel this_ptr_conv;
22759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22760         this_ptr_conv.is_owned = false;
22761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22762         int8_tArray ret_arr = init_int8_tArray(32);
22763         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
22764         return ret_arr;
22765 }
22766
22767 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22768         LDKOpenChannel this_ptr_conv;
22769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22770         this_ptr_conv.is_owned = false;
22771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22772         LDKThirtyTwoBytes val_ref;
22773         CHECK(val->arr_len == 32);
22774         memcpy(val_ref.data, val->elems, 32);
22775         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22776 }
22777
22778 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
22779         LDKOpenChannel this_ptr_conv;
22780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22781         this_ptr_conv.is_owned = false;
22782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22783         int8_tArray ret_arr = init_int8_tArray(32);
22784         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22785         return ret_arr;
22786 }
22787
22788 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22789         LDKOpenChannel this_ptr_conv;
22790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22791         this_ptr_conv.is_owned = false;
22792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22793         LDKThirtyTwoBytes val_ref;
22794         CHECK(val->arr_len == 32);
22795         memcpy(val_ref.data, val->elems, 32);
22796         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22797 }
22798
22799 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
22800         LDKOpenChannel this_ptr_conv;
22801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22802         this_ptr_conv.is_owned = false;
22803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22804         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22805         return ret_val;
22806 }
22807
22808 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
22809         LDKOpenChannel this_ptr_conv;
22810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22811         this_ptr_conv.is_owned = false;
22812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22813         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22814 }
22815
22816 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
22817         LDKOpenChannel this_ptr_conv;
22818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22819         this_ptr_conv.is_owned = false;
22820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22821         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22822         return ret_val;
22823 }
22824
22825 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
22826         LDKOpenChannel this_ptr_conv;
22827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22828         this_ptr_conv.is_owned = false;
22829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22830         OpenChannel_set_push_msat(&this_ptr_conv, val);
22831 }
22832
22833 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22834         LDKOpenChannel this_ptr_conv;
22835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22836         this_ptr_conv.is_owned = false;
22837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22838         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22839         return ret_val;
22840 }
22841
22842 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22843         LDKOpenChannel this_ptr_conv;
22844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22845         this_ptr_conv.is_owned = false;
22846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22847         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22848 }
22849
22850 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) {
22851         LDKOpenChannel this_ptr_conv;
22852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22853         this_ptr_conv.is_owned = false;
22854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22855         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22856         return ret_val;
22857 }
22858
22859 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) {
22860         LDKOpenChannel this_ptr_conv;
22861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22862         this_ptr_conv.is_owned = false;
22863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22864         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22865 }
22866
22867 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
22868         LDKOpenChannel this_ptr_conv;
22869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22870         this_ptr_conv.is_owned = false;
22871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22872         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22873         return ret_val;
22874 }
22875
22876 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22877         LDKOpenChannel this_ptr_conv;
22878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22879         this_ptr_conv.is_owned = false;
22880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22881         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22882 }
22883
22884 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
22885         LDKOpenChannel this_ptr_conv;
22886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22887         this_ptr_conv.is_owned = false;
22888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22889         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
22890         return ret_val;
22891 }
22892
22893 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22894         LDKOpenChannel this_ptr_conv;
22895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22896         this_ptr_conv.is_owned = false;
22897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22898         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22899 }
22900
22901 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
22902         LDKOpenChannel this_ptr_conv;
22903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22904         this_ptr_conv.is_owned = false;
22905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22906         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
22907         return ret_val;
22908 }
22909
22910 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
22911         LDKOpenChannel this_ptr_conv;
22912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22913         this_ptr_conv.is_owned = false;
22914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22915         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
22916 }
22917
22918 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
22919         LDKOpenChannel this_ptr_conv;
22920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22921         this_ptr_conv.is_owned = false;
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22923         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
22924         return ret_val;
22925 }
22926
22927 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22928         LDKOpenChannel this_ptr_conv;
22929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22930         this_ptr_conv.is_owned = false;
22931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22932         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
22933 }
22934
22935 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
22936         LDKOpenChannel this_ptr_conv;
22937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22938         this_ptr_conv.is_owned = false;
22939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22940         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
22941         return ret_val;
22942 }
22943
22944 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22945         LDKOpenChannel this_ptr_conv;
22946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22947         this_ptr_conv.is_owned = false;
22948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22949         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22950 }
22951
22952 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
22953         LDKOpenChannel this_ptr_conv;
22954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22955         this_ptr_conv.is_owned = false;
22956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22957         int8_tArray ret_arr = init_int8_tArray(33);
22958         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22959         return ret_arr;
22960 }
22961
22962 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22963         LDKOpenChannel this_ptr_conv;
22964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22965         this_ptr_conv.is_owned = false;
22966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22967         LDKPublicKey val_ref;
22968         CHECK(val->arr_len == 33);
22969         memcpy(val_ref.compressed_form, val->elems, 33);
22970         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22971 }
22972
22973 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
22974         LDKOpenChannel this_ptr_conv;
22975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22976         this_ptr_conv.is_owned = false;
22977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22978         int8_tArray ret_arr = init_int8_tArray(33);
22979         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22980         return ret_arr;
22981 }
22982
22983 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22984         LDKOpenChannel this_ptr_conv;
22985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22986         this_ptr_conv.is_owned = false;
22987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22988         LDKPublicKey val_ref;
22989         CHECK(val->arr_len == 33);
22990         memcpy(val_ref.compressed_form, val->elems, 33);
22991         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
22992 }
22993
22994 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
22995         LDKOpenChannel this_ptr_conv;
22996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22997         this_ptr_conv.is_owned = false;
22998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22999         int8_tArray ret_arr = init_int8_tArray(33);
23000         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23001         return ret_arr;
23002 }
23003
23004 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23005         LDKOpenChannel this_ptr_conv;
23006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23007         this_ptr_conv.is_owned = false;
23008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23009         LDKPublicKey val_ref;
23010         CHECK(val->arr_len == 33);
23011         memcpy(val_ref.compressed_form, val->elems, 33);
23012         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
23013 }
23014
23015 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23016         LDKOpenChannel this_ptr_conv;
23017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23018         this_ptr_conv.is_owned = false;
23019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23020         int8_tArray ret_arr = init_int8_tArray(33);
23021         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23022         return ret_arr;
23023 }
23024
23025 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23026         LDKOpenChannel this_ptr_conv;
23027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23028         this_ptr_conv.is_owned = false;
23029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23030         LDKPublicKey val_ref;
23031         CHECK(val->arr_len == 33);
23032         memcpy(val_ref.compressed_form, val->elems, 33);
23033         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23034 }
23035
23036 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
23037         LDKOpenChannel this_ptr_conv;
23038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23039         this_ptr_conv.is_owned = false;
23040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23041         int8_tArray ret_arr = init_int8_tArray(33);
23042         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23043         return ret_arr;
23044 }
23045
23046 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23047         LDKOpenChannel this_ptr_conv;
23048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23049         this_ptr_conv.is_owned = false;
23050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23051         LDKPublicKey val_ref;
23052         CHECK(val->arr_len == 33);
23053         memcpy(val_ref.compressed_form, val->elems, 33);
23054         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23055 }
23056
23057 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23058         LDKOpenChannel this_ptr_conv;
23059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23060         this_ptr_conv.is_owned = false;
23061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23062         int8_tArray ret_arr = init_int8_tArray(33);
23063         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23064         return ret_arr;
23065 }
23066
23067 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) {
23068         LDKOpenChannel this_ptr_conv;
23069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23070         this_ptr_conv.is_owned = false;
23071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23072         LDKPublicKey val_ref;
23073         CHECK(val->arr_len == 33);
23074         memcpy(val_ref.compressed_form, val->elems, 33);
23075         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23076 }
23077
23078 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
23079         LDKOpenChannel this_ptr_conv;
23080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23081         this_ptr_conv.is_owned = false;
23082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23083         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
23084         return ret_val;
23085 }
23086
23087 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
23088         LDKOpenChannel this_ptr_conv;
23089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23090         this_ptr_conv.is_owned = false;
23091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23092         OpenChannel_set_channel_flags(&this_ptr_conv, val);
23093 }
23094
23095 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
23096         LDKOpenChannel this_ptr_conv;
23097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23098         this_ptr_conv.is_owned = false;
23099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23100         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
23101         uint64_t ret_ref = 0;
23102         if ((uint64_t)ret_var.inner > 4096) {
23103                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23104                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23106                 ret_ref = (uint64_t)ret_var.inner;
23107                 if (ret_var.is_owned) {
23108                         ret_ref |= 1;
23109                 }
23110         }
23111         return ret_ref;
23112 }
23113
23114 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
23115         LDKOpenChannel this_ptr_conv;
23116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23117         this_ptr_conv.is_owned = false;
23118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23119         LDKChannelTypeFeatures val_conv;
23120         val_conv.inner = (void*)(val & (~1));
23121         val_conv.is_owned = (val & 1) || (val == 0);
23122         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23123         val_conv = ChannelTypeFeatures_clone(&val_conv);
23124         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
23125 }
23126
23127 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
23128         LDKOpenChannel ret_var = OpenChannel_clone(arg);
23129 uint64_t ret_ref = 0;
23130 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23131 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23132 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23133 ret_ref = (uint64_t)ret_var.inner;
23134 if (ret_var.is_owned) {
23135         ret_ref |= 1;
23136 }
23137         return ret_ref;
23138 }
23139 int64_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
23140         LDKOpenChannel arg_conv;
23141         arg_conv.inner = (void*)(arg & (~1));
23142         arg_conv.is_owned = false;
23143         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23144         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
23145         return ret_val;
23146 }
23147
23148 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
23149         LDKOpenChannel orig_conv;
23150         orig_conv.inner = (void*)(orig & (~1));
23151         orig_conv.is_owned = false;
23152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23153         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
23154         uint64_t ret_ref = 0;
23155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23158         ret_ref = (uint64_t)ret_var.inner;
23159         if (ret_var.is_owned) {
23160                 ret_ref |= 1;
23161         }
23162         return ret_ref;
23163 }
23164
23165 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
23166         LDKAcceptChannel this_obj_conv;
23167         this_obj_conv.inner = (void*)(this_obj & (~1));
23168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23170         AcceptChannel_free(this_obj_conv);
23171 }
23172
23173 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
23174         LDKAcceptChannel this_ptr_conv;
23175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23176         this_ptr_conv.is_owned = false;
23177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23178         int8_tArray ret_arr = init_int8_tArray(32);
23179         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
23180         return ret_arr;
23181 }
23182
23183 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23184         LDKAcceptChannel this_ptr_conv;
23185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23186         this_ptr_conv.is_owned = false;
23187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23188         LDKThirtyTwoBytes val_ref;
23189         CHECK(val->arr_len == 32);
23190         memcpy(val_ref.data, val->elems, 32);
23191         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
23192 }
23193
23194 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
23195         LDKAcceptChannel this_ptr_conv;
23196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23197         this_ptr_conv.is_owned = false;
23198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23199         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
23200         return ret_val;
23201 }
23202
23203 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
23204         LDKAcceptChannel this_ptr_conv;
23205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23206         this_ptr_conv.is_owned = false;
23207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23208         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
23209 }
23210
23211 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) {
23212         LDKAcceptChannel this_ptr_conv;
23213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23214         this_ptr_conv.is_owned = false;
23215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23216         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
23217         return ret_val;
23218 }
23219
23220 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) {
23221         LDKAcceptChannel this_ptr_conv;
23222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23223         this_ptr_conv.is_owned = false;
23224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23225         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23226 }
23227
23228 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
23229         LDKAcceptChannel this_ptr_conv;
23230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23231         this_ptr_conv.is_owned = false;
23232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23233         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
23234         return ret_val;
23235 }
23236
23237 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
23238         LDKAcceptChannel this_ptr_conv;
23239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23240         this_ptr_conv.is_owned = false;
23241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23242         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
23243 }
23244
23245 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
23246         LDKAcceptChannel this_ptr_conv;
23247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23248         this_ptr_conv.is_owned = false;
23249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23250         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
23251         return ret_val;
23252 }
23253
23254 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
23255         LDKAcceptChannel this_ptr_conv;
23256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23257         this_ptr_conv.is_owned = false;
23258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23259         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
23260 }
23261
23262 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
23263         LDKAcceptChannel this_ptr_conv;
23264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23265         this_ptr_conv.is_owned = false;
23266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23267         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
23268         return ret_val;
23269 }
23270
23271 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
23272         LDKAcceptChannel this_ptr_conv;
23273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23274         this_ptr_conv.is_owned = false;
23275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23276         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
23277 }
23278
23279 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
23280         LDKAcceptChannel this_ptr_conv;
23281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23282         this_ptr_conv.is_owned = false;
23283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23284         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
23285         return ret_val;
23286 }
23287
23288 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23289         LDKAcceptChannel this_ptr_conv;
23290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23291         this_ptr_conv.is_owned = false;
23292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23293         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
23294 }
23295
23296 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
23297         LDKAcceptChannel this_ptr_conv;
23298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23299         this_ptr_conv.is_owned = false;
23300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23301         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
23302         return ret_val;
23303 }
23304
23305 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
23306         LDKAcceptChannel this_ptr_conv;
23307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23308         this_ptr_conv.is_owned = false;
23309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23310         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
23311 }
23312
23313 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
23314         LDKAcceptChannel this_ptr_conv;
23315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23316         this_ptr_conv.is_owned = false;
23317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23318         int8_tArray ret_arr = init_int8_tArray(33);
23319         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
23320         return ret_arr;
23321 }
23322
23323 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
23324         LDKAcceptChannel this_ptr_conv;
23325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23326         this_ptr_conv.is_owned = false;
23327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23328         LDKPublicKey val_ref;
23329         CHECK(val->arr_len == 33);
23330         memcpy(val_ref.compressed_form, val->elems, 33);
23331         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
23332 }
23333
23334 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
23335         LDKAcceptChannel this_ptr_conv;
23336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23337         this_ptr_conv.is_owned = false;
23338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23339         int8_tArray ret_arr = init_int8_tArray(33);
23340         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
23341         return ret_arr;
23342 }
23343
23344 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
23345         LDKAcceptChannel this_ptr_conv;
23346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23347         this_ptr_conv.is_owned = false;
23348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23349         LDKPublicKey val_ref;
23350         CHECK(val->arr_len == 33);
23351         memcpy(val_ref.compressed_form, val->elems, 33);
23352         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23353 }
23354
23355 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
23356         LDKAcceptChannel this_ptr_conv;
23357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23358         this_ptr_conv.is_owned = false;
23359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23360         int8_tArray ret_arr = init_int8_tArray(33);
23361         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23362         return ret_arr;
23363 }
23364
23365 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23366         LDKAcceptChannel this_ptr_conv;
23367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23368         this_ptr_conv.is_owned = false;
23369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23370         LDKPublicKey val_ref;
23371         CHECK(val->arr_len == 33);
23372         memcpy(val_ref.compressed_form, val->elems, 33);
23373         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
23374 }
23375
23376 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23377         LDKAcceptChannel this_ptr_conv;
23378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23379         this_ptr_conv.is_owned = false;
23380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23381         int8_tArray ret_arr = init_int8_tArray(33);
23382         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23383         return ret_arr;
23384 }
23385
23386 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23387         LDKAcceptChannel this_ptr_conv;
23388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23389         this_ptr_conv.is_owned = false;
23390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23391         LDKPublicKey val_ref;
23392         CHECK(val->arr_len == 33);
23393         memcpy(val_ref.compressed_form, val->elems, 33);
23394         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23395 }
23396
23397 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
23398         LDKAcceptChannel this_ptr_conv;
23399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23400         this_ptr_conv.is_owned = false;
23401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23402         int8_tArray ret_arr = init_int8_tArray(33);
23403         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23404         return ret_arr;
23405 }
23406
23407 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23408         LDKAcceptChannel this_ptr_conv;
23409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23410         this_ptr_conv.is_owned = false;
23411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23412         LDKPublicKey val_ref;
23413         CHECK(val->arr_len == 33);
23414         memcpy(val_ref.compressed_form, val->elems, 33);
23415         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23416 }
23417
23418 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23419         LDKAcceptChannel this_ptr_conv;
23420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23421         this_ptr_conv.is_owned = false;
23422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23423         int8_tArray ret_arr = init_int8_tArray(33);
23424         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23425         return ret_arr;
23426 }
23427
23428 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) {
23429         LDKAcceptChannel this_ptr_conv;
23430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23431         this_ptr_conv.is_owned = false;
23432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23433         LDKPublicKey val_ref;
23434         CHECK(val->arr_len == 33);
23435         memcpy(val_ref.compressed_form, val->elems, 33);
23436         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23437 }
23438
23439 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
23440         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
23441 uint64_t ret_ref = 0;
23442 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23443 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23445 ret_ref = (uint64_t)ret_var.inner;
23446 if (ret_var.is_owned) {
23447         ret_ref |= 1;
23448 }
23449         return ret_ref;
23450 }
23451 int64_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
23452         LDKAcceptChannel arg_conv;
23453         arg_conv.inner = (void*)(arg & (~1));
23454         arg_conv.is_owned = false;
23455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23456         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
23457         return ret_val;
23458 }
23459
23460 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
23461         LDKAcceptChannel orig_conv;
23462         orig_conv.inner = (void*)(orig & (~1));
23463         orig_conv.is_owned = false;
23464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23465         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
23466         uint64_t ret_ref = 0;
23467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23470         ret_ref = (uint64_t)ret_var.inner;
23471         if (ret_var.is_owned) {
23472                 ret_ref |= 1;
23473         }
23474         return ret_ref;
23475 }
23476
23477 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
23478         LDKFundingCreated this_obj_conv;
23479         this_obj_conv.inner = (void*)(this_obj & (~1));
23480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23482         FundingCreated_free(this_obj_conv);
23483 }
23484
23485 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
23486         LDKFundingCreated this_ptr_conv;
23487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23488         this_ptr_conv.is_owned = false;
23489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23490         int8_tArray ret_arr = init_int8_tArray(32);
23491         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
23492         return ret_arr;
23493 }
23494
23495 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23496         LDKFundingCreated this_ptr_conv;
23497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23498         this_ptr_conv.is_owned = false;
23499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23500         LDKThirtyTwoBytes val_ref;
23501         CHECK(val->arr_len == 32);
23502         memcpy(val_ref.data, val->elems, 32);
23503         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
23504 }
23505
23506 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
23507         LDKFundingCreated this_ptr_conv;
23508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23509         this_ptr_conv.is_owned = false;
23510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23511         int8_tArray ret_arr = init_int8_tArray(32);
23512         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
23513         return ret_arr;
23514 }
23515
23516 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
23517         LDKFundingCreated this_ptr_conv;
23518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23519         this_ptr_conv.is_owned = false;
23520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23521         LDKThirtyTwoBytes val_ref;
23522         CHECK(val->arr_len == 32);
23523         memcpy(val_ref.data, val->elems, 32);
23524         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
23525 }
23526
23527 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
23528         LDKFundingCreated this_ptr_conv;
23529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23530         this_ptr_conv.is_owned = false;
23531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23532         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
23533         return ret_val;
23534 }
23535
23536 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
23537         LDKFundingCreated this_ptr_conv;
23538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23539         this_ptr_conv.is_owned = false;
23540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23541         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
23542 }
23543
23544 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
23545         LDKFundingCreated this_ptr_conv;
23546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23547         this_ptr_conv.is_owned = false;
23548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23549         int8_tArray ret_arr = init_int8_tArray(64);
23550         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
23551         return ret_arr;
23552 }
23553
23554 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
23555         LDKFundingCreated this_ptr_conv;
23556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23557         this_ptr_conv.is_owned = false;
23558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23559         LDKSignature val_ref;
23560         CHECK(val->arr_len == 64);
23561         memcpy(val_ref.compact_form, val->elems, 64);
23562         FundingCreated_set_signature(&this_ptr_conv, val_ref);
23563 }
23564
23565 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) {
23566         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
23567         CHECK(temporary_channel_id_arg->arr_len == 32);
23568         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32);
23569         LDKThirtyTwoBytes funding_txid_arg_ref;
23570         CHECK(funding_txid_arg->arr_len == 32);
23571         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32);
23572         LDKSignature signature_arg_ref;
23573         CHECK(signature_arg->arr_len == 64);
23574         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
23575         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
23576         uint64_t ret_ref = 0;
23577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23580         ret_ref = (uint64_t)ret_var.inner;
23581         if (ret_var.is_owned) {
23582                 ret_ref |= 1;
23583         }
23584         return ret_ref;
23585 }
23586
23587 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
23588         LDKFundingCreated ret_var = FundingCreated_clone(arg);
23589 uint64_t ret_ref = 0;
23590 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23591 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
23594 if (ret_var.is_owned) {
23595         ret_ref |= 1;
23596 }
23597         return ret_ref;
23598 }
23599 int64_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
23600         LDKFundingCreated arg_conv;
23601         arg_conv.inner = (void*)(arg & (~1));
23602         arg_conv.is_owned = false;
23603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23604         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
23605         return ret_val;
23606 }
23607
23608 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
23609         LDKFundingCreated orig_conv;
23610         orig_conv.inner = (void*)(orig & (~1));
23611         orig_conv.is_owned = false;
23612         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23613         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
23614         uint64_t ret_ref = 0;
23615         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23616         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23618         ret_ref = (uint64_t)ret_var.inner;
23619         if (ret_var.is_owned) {
23620                 ret_ref |= 1;
23621         }
23622         return ret_ref;
23623 }
23624
23625 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
23626         LDKFundingSigned this_obj_conv;
23627         this_obj_conv.inner = (void*)(this_obj & (~1));
23628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23630         FundingSigned_free(this_obj_conv);
23631 }
23632
23633 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
23634         LDKFundingSigned this_ptr_conv;
23635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23636         this_ptr_conv.is_owned = false;
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23638         int8_tArray ret_arr = init_int8_tArray(32);
23639         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
23640         return ret_arr;
23641 }
23642
23643 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23644         LDKFundingSigned this_ptr_conv;
23645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23646         this_ptr_conv.is_owned = false;
23647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23648         LDKThirtyTwoBytes val_ref;
23649         CHECK(val->arr_len == 32);
23650         memcpy(val_ref.data, val->elems, 32);
23651         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
23652 }
23653
23654 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
23655         LDKFundingSigned this_ptr_conv;
23656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23657         this_ptr_conv.is_owned = false;
23658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23659         int8_tArray ret_arr = init_int8_tArray(64);
23660         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23661         return ret_arr;
23662 }
23663
23664 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23665         LDKFundingSigned this_ptr_conv;
23666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23667         this_ptr_conv.is_owned = false;
23668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23669         LDKSignature val_ref;
23670         CHECK(val->arr_len == 64);
23671         memcpy(val_ref.compact_form, val->elems, 64);
23672         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23673 }
23674
23675 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
23676         LDKThirtyTwoBytes channel_id_arg_ref;
23677         CHECK(channel_id_arg->arr_len == 32);
23678         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
23679         LDKSignature signature_arg_ref;
23680         CHECK(signature_arg->arr_len == 64);
23681         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
23682         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23683         uint64_t ret_ref = 0;
23684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23687         ret_ref = (uint64_t)ret_var.inner;
23688         if (ret_var.is_owned) {
23689                 ret_ref |= 1;
23690         }
23691         return ret_ref;
23692 }
23693
23694 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
23695         LDKFundingSigned ret_var = FundingSigned_clone(arg);
23696 uint64_t ret_ref = 0;
23697 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23698 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
23701 if (ret_var.is_owned) {
23702         ret_ref |= 1;
23703 }
23704         return ret_ref;
23705 }
23706 int64_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
23707         LDKFundingSigned arg_conv;
23708         arg_conv.inner = (void*)(arg & (~1));
23709         arg_conv.is_owned = false;
23710         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23711         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
23712         return ret_val;
23713 }
23714
23715 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
23716         LDKFundingSigned orig_conv;
23717         orig_conv.inner = (void*)(orig & (~1));
23718         orig_conv.is_owned = false;
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23720         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23721         uint64_t ret_ref = 0;
23722         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23723         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23725         ret_ref = (uint64_t)ret_var.inner;
23726         if (ret_var.is_owned) {
23727                 ret_ref |= 1;
23728         }
23729         return ret_ref;
23730 }
23731
23732 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
23733         LDKFundingLocked this_obj_conv;
23734         this_obj_conv.inner = (void*)(this_obj & (~1));
23735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23737         FundingLocked_free(this_obj_conv);
23738 }
23739
23740 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
23741         LDKFundingLocked this_ptr_conv;
23742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23743         this_ptr_conv.is_owned = false;
23744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23745         int8_tArray ret_arr = init_int8_tArray(32);
23746         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
23747         return ret_arr;
23748 }
23749
23750 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23751         LDKFundingLocked this_ptr_conv;
23752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23753         this_ptr_conv.is_owned = false;
23754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23755         LDKThirtyTwoBytes val_ref;
23756         CHECK(val->arr_len == 32);
23757         memcpy(val_ref.data, val->elems, 32);
23758         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23759 }
23760
23761 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
23762         LDKFundingLocked this_ptr_conv;
23763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23764         this_ptr_conv.is_owned = false;
23765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23766         int8_tArray ret_arr = init_int8_tArray(33);
23767         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23768         return ret_arr;
23769 }
23770
23771 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) {
23772         LDKFundingLocked this_ptr_conv;
23773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23774         this_ptr_conv.is_owned = false;
23775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23776         LDKPublicKey val_ref;
23777         CHECK(val->arr_len == 33);
23778         memcpy(val_ref.compressed_form, val->elems, 33);
23779         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23780 }
23781
23782 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
23783         LDKThirtyTwoBytes channel_id_arg_ref;
23784         CHECK(channel_id_arg->arr_len == 32);
23785         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
23786         LDKPublicKey next_per_commitment_point_arg_ref;
23787         CHECK(next_per_commitment_point_arg->arr_len == 33);
23788         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33);
23789         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23790         uint64_t ret_ref = 0;
23791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23794         ret_ref = (uint64_t)ret_var.inner;
23795         if (ret_var.is_owned) {
23796                 ret_ref |= 1;
23797         }
23798         return ret_ref;
23799 }
23800
23801 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
23802         LDKFundingLocked ret_var = FundingLocked_clone(arg);
23803 uint64_t ret_ref = 0;
23804 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23805 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
23808 if (ret_var.is_owned) {
23809         ret_ref |= 1;
23810 }
23811         return ret_ref;
23812 }
23813 int64_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
23814         LDKFundingLocked arg_conv;
23815         arg_conv.inner = (void*)(arg & (~1));
23816         arg_conv.is_owned = false;
23817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23818         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
23819         return ret_val;
23820 }
23821
23822 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
23823         LDKFundingLocked orig_conv;
23824         orig_conv.inner = (void*)(orig & (~1));
23825         orig_conv.is_owned = false;
23826         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23827         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23828         uint64_t ret_ref = 0;
23829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23832         ret_ref = (uint64_t)ret_var.inner;
23833         if (ret_var.is_owned) {
23834                 ret_ref |= 1;
23835         }
23836         return ret_ref;
23837 }
23838
23839 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
23840         LDKShutdown this_obj_conv;
23841         this_obj_conv.inner = (void*)(this_obj & (~1));
23842         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23844         Shutdown_free(this_obj_conv);
23845 }
23846
23847 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
23848         LDKShutdown this_ptr_conv;
23849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23850         this_ptr_conv.is_owned = false;
23851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23852         int8_tArray ret_arr = init_int8_tArray(32);
23853         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
23854         return ret_arr;
23855 }
23856
23857 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23858         LDKShutdown this_ptr_conv;
23859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23860         this_ptr_conv.is_owned = false;
23861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23862         LDKThirtyTwoBytes val_ref;
23863         CHECK(val->arr_len == 32);
23864         memcpy(val_ref.data, val->elems, 32);
23865         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
23866 }
23867
23868 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
23869         LDKShutdown this_ptr_conv;
23870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23871         this_ptr_conv.is_owned = false;
23872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23873         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
23874         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
23875         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23876         return ret_arr;
23877 }
23878
23879 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
23880         LDKShutdown this_ptr_conv;
23881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23882         this_ptr_conv.is_owned = false;
23883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23884         LDKCVec_u8Z val_ref;
23885         val_ref.datalen = val->arr_len;
23886         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23887         memcpy(val_ref.data, val->elems, val_ref.datalen);
23888         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
23889 }
23890
23891 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
23892         LDKThirtyTwoBytes channel_id_arg_ref;
23893         CHECK(channel_id_arg->arr_len == 32);
23894         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
23895         LDKCVec_u8Z scriptpubkey_arg_ref;
23896         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
23897         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23898         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen);
23899         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
23900         uint64_t ret_ref = 0;
23901         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23902         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23904         ret_ref = (uint64_t)ret_var.inner;
23905         if (ret_var.is_owned) {
23906                 ret_ref |= 1;
23907         }
23908         return ret_ref;
23909 }
23910
23911 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
23912         LDKShutdown ret_var = Shutdown_clone(arg);
23913 uint64_t ret_ref = 0;
23914 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23915 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
23918 if (ret_var.is_owned) {
23919         ret_ref |= 1;
23920 }
23921         return ret_ref;
23922 }
23923 int64_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
23924         LDKShutdown arg_conv;
23925         arg_conv.inner = (void*)(arg & (~1));
23926         arg_conv.is_owned = false;
23927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23928         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
23929         return ret_val;
23930 }
23931
23932 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
23933         LDKShutdown orig_conv;
23934         orig_conv.inner = (void*)(orig & (~1));
23935         orig_conv.is_owned = false;
23936         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23937         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
23938         uint64_t ret_ref = 0;
23939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23942         ret_ref = (uint64_t)ret_var.inner;
23943         if (ret_var.is_owned) {
23944                 ret_ref |= 1;
23945         }
23946         return ret_ref;
23947 }
23948
23949 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
23950         LDKClosingSignedFeeRange this_obj_conv;
23951         this_obj_conv.inner = (void*)(this_obj & (~1));
23952         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23954         ClosingSignedFeeRange_free(this_obj_conv);
23955 }
23956
23957 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
23958         LDKClosingSignedFeeRange this_ptr_conv;
23959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23960         this_ptr_conv.is_owned = false;
23961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23962         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
23963         return ret_val;
23964 }
23965
23966 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
23967         LDKClosingSignedFeeRange this_ptr_conv;
23968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23969         this_ptr_conv.is_owned = false;
23970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23971         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
23972 }
23973
23974 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
23975         LDKClosingSignedFeeRange this_ptr_conv;
23976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23977         this_ptr_conv.is_owned = false;
23978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23979         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
23980         return ret_val;
23981 }
23982
23983 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
23984         LDKClosingSignedFeeRange this_ptr_conv;
23985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23986         this_ptr_conv.is_owned = false;
23987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23988         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
23989 }
23990
23991 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
23992         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
23993         uint64_t ret_ref = 0;
23994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23997         ret_ref = (uint64_t)ret_var.inner;
23998         if (ret_var.is_owned) {
23999                 ret_ref |= 1;
24000         }
24001         return ret_ref;
24002 }
24003
24004 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
24005         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
24006 uint64_t ret_ref = 0;
24007 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24008 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24011 if (ret_var.is_owned) {
24012         ret_ref |= 1;
24013 }
24014         return ret_ref;
24015 }
24016 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
24017         LDKClosingSignedFeeRange arg_conv;
24018         arg_conv.inner = (void*)(arg & (~1));
24019         arg_conv.is_owned = false;
24020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24021         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
24022         return ret_val;
24023 }
24024
24025 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
24026         LDKClosingSignedFeeRange orig_conv;
24027         orig_conv.inner = (void*)(orig & (~1));
24028         orig_conv.is_owned = false;
24029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24030         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
24031         uint64_t ret_ref = 0;
24032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24035         ret_ref = (uint64_t)ret_var.inner;
24036         if (ret_var.is_owned) {
24037                 ret_ref |= 1;
24038         }
24039         return ret_ref;
24040 }
24041
24042 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
24043         LDKClosingSigned this_obj_conv;
24044         this_obj_conv.inner = (void*)(this_obj & (~1));
24045         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24047         ClosingSigned_free(this_obj_conv);
24048 }
24049
24050 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
24051         LDKClosingSigned this_ptr_conv;
24052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24053         this_ptr_conv.is_owned = false;
24054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24055         int8_tArray ret_arr = init_int8_tArray(32);
24056         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
24057         return ret_arr;
24058 }
24059
24060 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24061         LDKClosingSigned this_ptr_conv;
24062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24063         this_ptr_conv.is_owned = false;
24064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24065         LDKThirtyTwoBytes val_ref;
24066         CHECK(val->arr_len == 32);
24067         memcpy(val_ref.data, val->elems, 32);
24068         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
24069 }
24070
24071 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
24072         LDKClosingSigned this_ptr_conv;
24073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24074         this_ptr_conv.is_owned = false;
24075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24076         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
24077         return ret_val;
24078 }
24079
24080 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
24081         LDKClosingSigned this_ptr_conv;
24082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24083         this_ptr_conv.is_owned = false;
24084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24085         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
24086 }
24087
24088 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
24089         LDKClosingSigned this_ptr_conv;
24090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24091         this_ptr_conv.is_owned = false;
24092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24093         int8_tArray ret_arr = init_int8_tArray(64);
24094         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
24095         return ret_arr;
24096 }
24097
24098 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24099         LDKClosingSigned this_ptr_conv;
24100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24101         this_ptr_conv.is_owned = false;
24102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24103         LDKSignature val_ref;
24104         CHECK(val->arr_len == 64);
24105         memcpy(val_ref.compact_form, val->elems, 64);
24106         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
24107 }
24108
24109 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
24110         LDKClosingSigned this_ptr_conv;
24111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24112         this_ptr_conv.is_owned = false;
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24114         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
24115         uint64_t ret_ref = 0;
24116         if ((uint64_t)ret_var.inner > 4096) {
24117                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24118                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24120                 ret_ref = (uint64_t)ret_var.inner;
24121                 if (ret_var.is_owned) {
24122                         ret_ref |= 1;
24123                 }
24124         }
24125         return ret_ref;
24126 }
24127
24128 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
24129         LDKClosingSigned this_ptr_conv;
24130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24131         this_ptr_conv.is_owned = false;
24132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24133         LDKClosingSignedFeeRange val_conv;
24134         val_conv.inner = (void*)(val & (~1));
24135         val_conv.is_owned = (val & 1) || (val == 0);
24136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24137         val_conv = ClosingSignedFeeRange_clone(&val_conv);
24138         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
24139 }
24140
24141 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) {
24142         LDKThirtyTwoBytes channel_id_arg_ref;
24143         CHECK(channel_id_arg->arr_len == 32);
24144         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
24145         LDKSignature signature_arg_ref;
24146         CHECK(signature_arg->arr_len == 64);
24147         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
24148         LDKClosingSignedFeeRange fee_range_arg_conv;
24149         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
24150         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
24151         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
24152         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
24153         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
24154         uint64_t ret_ref = 0;
24155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24158         ret_ref = (uint64_t)ret_var.inner;
24159         if (ret_var.is_owned) {
24160                 ret_ref |= 1;
24161         }
24162         return ret_ref;
24163 }
24164
24165 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
24166         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
24167 uint64_t ret_ref = 0;
24168 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24169 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24172 if (ret_var.is_owned) {
24173         ret_ref |= 1;
24174 }
24175         return ret_ref;
24176 }
24177 int64_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
24178         LDKClosingSigned arg_conv;
24179         arg_conv.inner = (void*)(arg & (~1));
24180         arg_conv.is_owned = false;
24181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24182         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
24183         return ret_val;
24184 }
24185
24186 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
24187         LDKClosingSigned orig_conv;
24188         orig_conv.inner = (void*)(orig & (~1));
24189         orig_conv.is_owned = false;
24190         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24191         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
24192         uint64_t ret_ref = 0;
24193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24196         ret_ref = (uint64_t)ret_var.inner;
24197         if (ret_var.is_owned) {
24198                 ret_ref |= 1;
24199         }
24200         return ret_ref;
24201 }
24202
24203 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
24204         LDKUpdateAddHTLC this_obj_conv;
24205         this_obj_conv.inner = (void*)(this_obj & (~1));
24206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24208         UpdateAddHTLC_free(this_obj_conv);
24209 }
24210
24211 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
24212         LDKUpdateAddHTLC this_ptr_conv;
24213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24214         this_ptr_conv.is_owned = false;
24215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24216         int8_tArray ret_arr = init_int8_tArray(32);
24217         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
24218         return ret_arr;
24219 }
24220
24221 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24222         LDKUpdateAddHTLC this_ptr_conv;
24223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24224         this_ptr_conv.is_owned = false;
24225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24226         LDKThirtyTwoBytes val_ref;
24227         CHECK(val->arr_len == 32);
24228         memcpy(val_ref.data, val->elems, 32);
24229         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
24230 }
24231
24232 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
24233         LDKUpdateAddHTLC this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24237         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
24238         return ret_val;
24239 }
24240
24241 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24242         LDKUpdateAddHTLC this_ptr_conv;
24243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24244         this_ptr_conv.is_owned = false;
24245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24246         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
24247 }
24248
24249 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
24250         LDKUpdateAddHTLC this_ptr_conv;
24251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24252         this_ptr_conv.is_owned = false;
24253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24254         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
24255         return ret_val;
24256 }
24257
24258 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
24259         LDKUpdateAddHTLC this_ptr_conv;
24260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24261         this_ptr_conv.is_owned = false;
24262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24263         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
24264 }
24265
24266 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
24267         LDKUpdateAddHTLC this_ptr_conv;
24268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24269         this_ptr_conv.is_owned = false;
24270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24271         int8_tArray ret_arr = init_int8_tArray(32);
24272         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
24273         return ret_arr;
24274 }
24275
24276 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
24277         LDKUpdateAddHTLC this_ptr_conv;
24278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24279         this_ptr_conv.is_owned = false;
24280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24281         LDKThirtyTwoBytes val_ref;
24282         CHECK(val->arr_len == 32);
24283         memcpy(val_ref.data, val->elems, 32);
24284         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
24285 }
24286
24287 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
24288         LDKUpdateAddHTLC this_ptr_conv;
24289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24290         this_ptr_conv.is_owned = false;
24291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24292         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
24293         return ret_val;
24294 }
24295
24296 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
24297         LDKUpdateAddHTLC this_ptr_conv;
24298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24299         this_ptr_conv.is_owned = false;
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24301         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
24302 }
24303
24304 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
24305         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
24306 uint64_t ret_ref = 0;
24307 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24308 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24310 ret_ref = (uint64_t)ret_var.inner;
24311 if (ret_var.is_owned) {
24312         ret_ref |= 1;
24313 }
24314         return ret_ref;
24315 }
24316 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
24317         LDKUpdateAddHTLC arg_conv;
24318         arg_conv.inner = (void*)(arg & (~1));
24319         arg_conv.is_owned = false;
24320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24321         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
24322         return ret_val;
24323 }
24324
24325 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
24326         LDKUpdateAddHTLC orig_conv;
24327         orig_conv.inner = (void*)(orig & (~1));
24328         orig_conv.is_owned = false;
24329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24330         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
24331         uint64_t ret_ref = 0;
24332         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24333         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24335         ret_ref = (uint64_t)ret_var.inner;
24336         if (ret_var.is_owned) {
24337                 ret_ref |= 1;
24338         }
24339         return ret_ref;
24340 }
24341
24342 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
24343         LDKUpdateFulfillHTLC this_obj_conv;
24344         this_obj_conv.inner = (void*)(this_obj & (~1));
24345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24347         UpdateFulfillHTLC_free(this_obj_conv);
24348 }
24349
24350 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
24351         LDKUpdateFulfillHTLC this_ptr_conv;
24352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24353         this_ptr_conv.is_owned = false;
24354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24355         int8_tArray ret_arr = init_int8_tArray(32);
24356         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
24357         return ret_arr;
24358 }
24359
24360 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24361         LDKUpdateFulfillHTLC this_ptr_conv;
24362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24363         this_ptr_conv.is_owned = false;
24364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24365         LDKThirtyTwoBytes val_ref;
24366         CHECK(val->arr_len == 32);
24367         memcpy(val_ref.data, val->elems, 32);
24368         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
24369 }
24370
24371 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
24372         LDKUpdateFulfillHTLC this_ptr_conv;
24373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24374         this_ptr_conv.is_owned = false;
24375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24376         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
24377         return ret_val;
24378 }
24379
24380 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24381         LDKUpdateFulfillHTLC this_ptr_conv;
24382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24383         this_ptr_conv.is_owned = false;
24384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24385         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
24386 }
24387
24388 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
24389         LDKUpdateFulfillHTLC this_ptr_conv;
24390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24391         this_ptr_conv.is_owned = false;
24392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24393         int8_tArray ret_arr = init_int8_tArray(32);
24394         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
24395         return ret_arr;
24396 }
24397
24398 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
24399         LDKUpdateFulfillHTLC this_ptr_conv;
24400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24401         this_ptr_conv.is_owned = false;
24402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24403         LDKThirtyTwoBytes val_ref;
24404         CHECK(val->arr_len == 32);
24405         memcpy(val_ref.data, val->elems, 32);
24406         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
24407 }
24408
24409 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) {
24410         LDKThirtyTwoBytes channel_id_arg_ref;
24411         CHECK(channel_id_arg->arr_len == 32);
24412         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
24413         LDKThirtyTwoBytes payment_preimage_arg_ref;
24414         CHECK(payment_preimage_arg->arr_len == 32);
24415         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32);
24416         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
24417         uint64_t ret_ref = 0;
24418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24421         ret_ref = (uint64_t)ret_var.inner;
24422         if (ret_var.is_owned) {
24423                 ret_ref |= 1;
24424         }
24425         return ret_ref;
24426 }
24427
24428 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
24429         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
24430 uint64_t ret_ref = 0;
24431 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24432 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24435 if (ret_var.is_owned) {
24436         ret_ref |= 1;
24437 }
24438         return ret_ref;
24439 }
24440 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
24441         LDKUpdateFulfillHTLC arg_conv;
24442         arg_conv.inner = (void*)(arg & (~1));
24443         arg_conv.is_owned = false;
24444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24445         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
24446         return ret_val;
24447 }
24448
24449 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
24450         LDKUpdateFulfillHTLC orig_conv;
24451         orig_conv.inner = (void*)(orig & (~1));
24452         orig_conv.is_owned = false;
24453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24454         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
24455         uint64_t ret_ref = 0;
24456         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24457         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24459         ret_ref = (uint64_t)ret_var.inner;
24460         if (ret_var.is_owned) {
24461                 ret_ref |= 1;
24462         }
24463         return ret_ref;
24464 }
24465
24466 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
24467         LDKUpdateFailHTLC this_obj_conv;
24468         this_obj_conv.inner = (void*)(this_obj & (~1));
24469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24471         UpdateFailHTLC_free(this_obj_conv);
24472 }
24473
24474 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
24475         LDKUpdateFailHTLC this_ptr_conv;
24476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24477         this_ptr_conv.is_owned = false;
24478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24479         int8_tArray ret_arr = init_int8_tArray(32);
24480         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
24481         return ret_arr;
24482 }
24483
24484 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24485         LDKUpdateFailHTLC this_ptr_conv;
24486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24487         this_ptr_conv.is_owned = false;
24488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24489         LDKThirtyTwoBytes val_ref;
24490         CHECK(val->arr_len == 32);
24491         memcpy(val_ref.data, val->elems, 32);
24492         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
24493 }
24494
24495 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
24496         LDKUpdateFailHTLC this_ptr_conv;
24497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24498         this_ptr_conv.is_owned = false;
24499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24500         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
24501         return ret_val;
24502 }
24503
24504 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24505         LDKUpdateFailHTLC this_ptr_conv;
24506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24507         this_ptr_conv.is_owned = false;
24508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24509         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
24510 }
24511
24512 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
24513         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
24514 uint64_t ret_ref = 0;
24515 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24516 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24518 ret_ref = (uint64_t)ret_var.inner;
24519 if (ret_var.is_owned) {
24520         ret_ref |= 1;
24521 }
24522         return ret_ref;
24523 }
24524 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
24525         LDKUpdateFailHTLC arg_conv;
24526         arg_conv.inner = (void*)(arg & (~1));
24527         arg_conv.is_owned = false;
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24529         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
24530         return ret_val;
24531 }
24532
24533 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
24534         LDKUpdateFailHTLC orig_conv;
24535         orig_conv.inner = (void*)(orig & (~1));
24536         orig_conv.is_owned = false;
24537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24538         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
24539         uint64_t ret_ref = 0;
24540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24543         ret_ref = (uint64_t)ret_var.inner;
24544         if (ret_var.is_owned) {
24545                 ret_ref |= 1;
24546         }
24547         return ret_ref;
24548 }
24549
24550 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
24551         LDKUpdateFailMalformedHTLC this_obj_conv;
24552         this_obj_conv.inner = (void*)(this_obj & (~1));
24553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24555         UpdateFailMalformedHTLC_free(this_obj_conv);
24556 }
24557
24558 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
24559         LDKUpdateFailMalformedHTLC this_ptr_conv;
24560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24561         this_ptr_conv.is_owned = false;
24562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24563         int8_tArray ret_arr = init_int8_tArray(32);
24564         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
24565         return ret_arr;
24566 }
24567
24568 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24569         LDKUpdateFailMalformedHTLC this_ptr_conv;
24570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24571         this_ptr_conv.is_owned = false;
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24573         LDKThirtyTwoBytes val_ref;
24574         CHECK(val->arr_len == 32);
24575         memcpy(val_ref.data, val->elems, 32);
24576         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
24577 }
24578
24579 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
24580         LDKUpdateFailMalformedHTLC this_ptr_conv;
24581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24582         this_ptr_conv.is_owned = false;
24583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24584         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
24585         return ret_val;
24586 }
24587
24588 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24589         LDKUpdateFailMalformedHTLC this_ptr_conv;
24590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24591         this_ptr_conv.is_owned = false;
24592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24593         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
24594 }
24595
24596 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
24597         LDKUpdateFailMalformedHTLC this_ptr_conv;
24598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24599         this_ptr_conv.is_owned = false;
24600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24601         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
24602         return ret_val;
24603 }
24604
24605 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
24606         LDKUpdateFailMalformedHTLC this_ptr_conv;
24607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24608         this_ptr_conv.is_owned = false;
24609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24610         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
24611 }
24612
24613 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
24614         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
24615 uint64_t ret_ref = 0;
24616 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24617 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24618 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24619 ret_ref = (uint64_t)ret_var.inner;
24620 if (ret_var.is_owned) {
24621         ret_ref |= 1;
24622 }
24623         return ret_ref;
24624 }
24625 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
24626         LDKUpdateFailMalformedHTLC arg_conv;
24627         arg_conv.inner = (void*)(arg & (~1));
24628         arg_conv.is_owned = false;
24629         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24630         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
24631         return ret_val;
24632 }
24633
24634 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
24635         LDKUpdateFailMalformedHTLC orig_conv;
24636         orig_conv.inner = (void*)(orig & (~1));
24637         orig_conv.is_owned = false;
24638         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24639         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
24640         uint64_t ret_ref = 0;
24641         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24642         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24644         ret_ref = (uint64_t)ret_var.inner;
24645         if (ret_var.is_owned) {
24646                 ret_ref |= 1;
24647         }
24648         return ret_ref;
24649 }
24650
24651 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
24652         LDKCommitmentSigned this_obj_conv;
24653         this_obj_conv.inner = (void*)(this_obj & (~1));
24654         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24656         CommitmentSigned_free(this_obj_conv);
24657 }
24658
24659 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
24660         LDKCommitmentSigned this_ptr_conv;
24661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24662         this_ptr_conv.is_owned = false;
24663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24664         int8_tArray ret_arr = init_int8_tArray(32);
24665         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
24666         return ret_arr;
24667 }
24668
24669 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24670         LDKCommitmentSigned this_ptr_conv;
24671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24672         this_ptr_conv.is_owned = false;
24673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24674         LDKThirtyTwoBytes val_ref;
24675         CHECK(val->arr_len == 32);
24676         memcpy(val_ref.data, val->elems, 32);
24677         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
24678 }
24679
24680 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
24681         LDKCommitmentSigned this_ptr_conv;
24682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24683         this_ptr_conv.is_owned = false;
24684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24685         int8_tArray ret_arr = init_int8_tArray(64);
24686         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
24687         return ret_arr;
24688 }
24689
24690 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24691         LDKCommitmentSigned this_ptr_conv;
24692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24693         this_ptr_conv.is_owned = false;
24694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24695         LDKSignature val_ref;
24696         CHECK(val->arr_len == 64);
24697         memcpy(val_ref.compact_form, val->elems, 64);
24698         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
24699 }
24700
24701 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
24702         LDKCommitmentSigned this_ptr_conv;
24703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24704         this_ptr_conv.is_owned = false;
24705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24706         LDKCVec_SignatureZ val_constr;
24707         val_constr.datalen = val->arr_len;
24708         if (val_constr.datalen > 0)
24709                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24710         else
24711                 val_constr.data = NULL;
24712         int8_tArray* val_vals = (void*) val->elems;
24713         for (size_t m = 0; m < val_constr.datalen; m++) {
24714                 int8_tArray val_conv_12 = val_vals[m];
24715                 LDKSignature val_conv_12_ref;
24716                 CHECK(val_conv_12->arr_len == 64);
24717                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64);
24718                 val_constr.data[m] = val_conv_12_ref;
24719         }
24720         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
24721 }
24722
24723 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
24724         LDKThirtyTwoBytes channel_id_arg_ref;
24725         CHECK(channel_id_arg->arr_len == 32);
24726         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
24727         LDKSignature signature_arg_ref;
24728         CHECK(signature_arg->arr_len == 64);
24729         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
24730         LDKCVec_SignatureZ htlc_signatures_arg_constr;
24731         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
24732         if (htlc_signatures_arg_constr.datalen > 0)
24733                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24734         else
24735                 htlc_signatures_arg_constr.data = NULL;
24736         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
24737         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
24738                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
24739                 LDKSignature htlc_signatures_arg_conv_12_ref;
24740                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
24741                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64);
24742                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
24743         }
24744         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
24745         uint64_t ret_ref = 0;
24746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24749         ret_ref = (uint64_t)ret_var.inner;
24750         if (ret_var.is_owned) {
24751                 ret_ref |= 1;
24752         }
24753         return ret_ref;
24754 }
24755
24756 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
24757         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
24758 uint64_t ret_ref = 0;
24759 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24760 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24763 if (ret_var.is_owned) {
24764         ret_ref |= 1;
24765 }
24766         return ret_ref;
24767 }
24768 int64_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
24769         LDKCommitmentSigned arg_conv;
24770         arg_conv.inner = (void*)(arg & (~1));
24771         arg_conv.is_owned = false;
24772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24773         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
24774         return ret_val;
24775 }
24776
24777 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
24778         LDKCommitmentSigned orig_conv;
24779         orig_conv.inner = (void*)(orig & (~1));
24780         orig_conv.is_owned = false;
24781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24782         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
24783         uint64_t ret_ref = 0;
24784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24787         ret_ref = (uint64_t)ret_var.inner;
24788         if (ret_var.is_owned) {
24789                 ret_ref |= 1;
24790         }
24791         return ret_ref;
24792 }
24793
24794 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
24795         LDKRevokeAndACK this_obj_conv;
24796         this_obj_conv.inner = (void*)(this_obj & (~1));
24797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24799         RevokeAndACK_free(this_obj_conv);
24800 }
24801
24802 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
24803         LDKRevokeAndACK this_ptr_conv;
24804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24805         this_ptr_conv.is_owned = false;
24806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24807         int8_tArray ret_arr = init_int8_tArray(32);
24808         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
24809         return ret_arr;
24810 }
24811
24812 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24813         LDKRevokeAndACK this_ptr_conv;
24814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24815         this_ptr_conv.is_owned = false;
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24817         LDKThirtyTwoBytes val_ref;
24818         CHECK(val->arr_len == 32);
24819         memcpy(val_ref.data, val->elems, 32);
24820         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
24821 }
24822
24823 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
24824         LDKRevokeAndACK this_ptr_conv;
24825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24826         this_ptr_conv.is_owned = false;
24827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24828         int8_tArray ret_arr = init_int8_tArray(32);
24829         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
24830         return ret_arr;
24831 }
24832
24833 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24834         LDKRevokeAndACK this_ptr_conv;
24835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24836         this_ptr_conv.is_owned = false;
24837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24838         LDKThirtyTwoBytes val_ref;
24839         CHECK(val->arr_len == 32);
24840         memcpy(val_ref.data, val->elems, 32);
24841         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
24842 }
24843
24844 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
24845         LDKRevokeAndACK this_ptr_conv;
24846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24847         this_ptr_conv.is_owned = false;
24848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24849         int8_tArray ret_arr = init_int8_tArray(33);
24850         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24851         return ret_arr;
24852 }
24853
24854 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) {
24855         LDKRevokeAndACK this_ptr_conv;
24856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24857         this_ptr_conv.is_owned = false;
24858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24859         LDKPublicKey val_ref;
24860         CHECK(val->arr_len == 33);
24861         memcpy(val_ref.compressed_form, val->elems, 33);
24862         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
24863 }
24864
24865 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) {
24866         LDKThirtyTwoBytes channel_id_arg_ref;
24867         CHECK(channel_id_arg->arr_len == 32);
24868         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
24869         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
24870         CHECK(per_commitment_secret_arg->arr_len == 32);
24871         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32);
24872         LDKPublicKey next_per_commitment_point_arg_ref;
24873         CHECK(next_per_commitment_point_arg->arr_len == 33);
24874         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33);
24875         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
24876         uint64_t ret_ref = 0;
24877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24880         ret_ref = (uint64_t)ret_var.inner;
24881         if (ret_var.is_owned) {
24882                 ret_ref |= 1;
24883         }
24884         return ret_ref;
24885 }
24886
24887 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
24888         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
24889 uint64_t ret_ref = 0;
24890 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24891 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24894 if (ret_var.is_owned) {
24895         ret_ref |= 1;
24896 }
24897         return ret_ref;
24898 }
24899 int64_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
24900         LDKRevokeAndACK arg_conv;
24901         arg_conv.inner = (void*)(arg & (~1));
24902         arg_conv.is_owned = false;
24903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24904         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
24905         return ret_val;
24906 }
24907
24908 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
24909         LDKRevokeAndACK orig_conv;
24910         orig_conv.inner = (void*)(orig & (~1));
24911         orig_conv.is_owned = false;
24912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24913         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
24914         uint64_t ret_ref = 0;
24915         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24916         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24918         ret_ref = (uint64_t)ret_var.inner;
24919         if (ret_var.is_owned) {
24920                 ret_ref |= 1;
24921         }
24922         return ret_ref;
24923 }
24924
24925 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
24926         LDKUpdateFee this_obj_conv;
24927         this_obj_conv.inner = (void*)(this_obj & (~1));
24928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24930         UpdateFee_free(this_obj_conv);
24931 }
24932
24933 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
24934         LDKUpdateFee this_ptr_conv;
24935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24936         this_ptr_conv.is_owned = false;
24937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24938         int8_tArray ret_arr = init_int8_tArray(32);
24939         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
24940         return ret_arr;
24941 }
24942
24943 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24944         LDKUpdateFee this_ptr_conv;
24945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24946         this_ptr_conv.is_owned = false;
24947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24948         LDKThirtyTwoBytes val_ref;
24949         CHECK(val->arr_len == 32);
24950         memcpy(val_ref.data, val->elems, 32);
24951         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
24952 }
24953
24954 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
24955         LDKUpdateFee this_ptr_conv;
24956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24957         this_ptr_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24959         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
24960         return ret_val;
24961 }
24962
24963 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
24964         LDKUpdateFee this_ptr_conv;
24965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24966         this_ptr_conv.is_owned = false;
24967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24968         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
24969 }
24970
24971 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
24972         LDKThirtyTwoBytes channel_id_arg_ref;
24973         CHECK(channel_id_arg->arr_len == 32);
24974         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
24975         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
24976         uint64_t ret_ref = 0;
24977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24980         ret_ref = (uint64_t)ret_var.inner;
24981         if (ret_var.is_owned) {
24982                 ret_ref |= 1;
24983         }
24984         return ret_ref;
24985 }
24986
24987 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
24988         LDKUpdateFee ret_var = UpdateFee_clone(arg);
24989 uint64_t ret_ref = 0;
24990 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24991 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
24994 if (ret_var.is_owned) {
24995         ret_ref |= 1;
24996 }
24997         return ret_ref;
24998 }
24999 int64_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
25000         LDKUpdateFee arg_conv;
25001         arg_conv.inner = (void*)(arg & (~1));
25002         arg_conv.is_owned = false;
25003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25004         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
25005         return ret_val;
25006 }
25007
25008 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
25009         LDKUpdateFee orig_conv;
25010         orig_conv.inner = (void*)(orig & (~1));
25011         orig_conv.is_owned = false;
25012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25013         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
25014         uint64_t ret_ref = 0;
25015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25018         ret_ref = (uint64_t)ret_var.inner;
25019         if (ret_var.is_owned) {
25020                 ret_ref |= 1;
25021         }
25022         return ret_ref;
25023 }
25024
25025 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
25026         LDKDataLossProtect this_obj_conv;
25027         this_obj_conv.inner = (void*)(this_obj & (~1));
25028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25030         DataLossProtect_free(this_obj_conv);
25031 }
25032
25033 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) {
25034         LDKDataLossProtect this_ptr_conv;
25035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25036         this_ptr_conv.is_owned = false;
25037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25038         int8_tArray ret_arr = init_int8_tArray(32);
25039         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
25040         return ret_arr;
25041 }
25042
25043 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) {
25044         LDKDataLossProtect this_ptr_conv;
25045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25046         this_ptr_conv.is_owned = false;
25047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25048         LDKThirtyTwoBytes val_ref;
25049         CHECK(val->arr_len == 32);
25050         memcpy(val_ref.data, val->elems, 32);
25051         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
25052 }
25053
25054 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) {
25055         LDKDataLossProtect this_ptr_conv;
25056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25057         this_ptr_conv.is_owned = false;
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25059         int8_tArray ret_arr = init_int8_tArray(33);
25060         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
25061         return ret_arr;
25062 }
25063
25064 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) {
25065         LDKDataLossProtect this_ptr_conv;
25066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25067         this_ptr_conv.is_owned = false;
25068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25069         LDKPublicKey val_ref;
25070         CHECK(val->arr_len == 33);
25071         memcpy(val_ref.compressed_form, val->elems, 33);
25072         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
25073 }
25074
25075 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) {
25076         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
25077         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
25078         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32);
25079         LDKPublicKey my_current_per_commitment_point_arg_ref;
25080         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
25081         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg->elems, 33);
25082         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
25083         uint64_t ret_ref = 0;
25084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25087         ret_ref = (uint64_t)ret_var.inner;
25088         if (ret_var.is_owned) {
25089                 ret_ref |= 1;
25090         }
25091         return ret_ref;
25092 }
25093
25094 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
25095         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
25096 uint64_t ret_ref = 0;
25097 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25098 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
25101 if (ret_var.is_owned) {
25102         ret_ref |= 1;
25103 }
25104         return ret_ref;
25105 }
25106 int64_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
25107         LDKDataLossProtect arg_conv;
25108         arg_conv.inner = (void*)(arg & (~1));
25109         arg_conv.is_owned = false;
25110         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25111         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
25112         return ret_val;
25113 }
25114
25115 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
25116         LDKDataLossProtect orig_conv;
25117         orig_conv.inner = (void*)(orig & (~1));
25118         orig_conv.is_owned = false;
25119         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25120         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
25121         uint64_t ret_ref = 0;
25122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25125         ret_ref = (uint64_t)ret_var.inner;
25126         if (ret_var.is_owned) {
25127                 ret_ref |= 1;
25128         }
25129         return ret_ref;
25130 }
25131
25132 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
25133         LDKChannelReestablish this_obj_conv;
25134         this_obj_conv.inner = (void*)(this_obj & (~1));
25135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25137         ChannelReestablish_free(this_obj_conv);
25138 }
25139
25140 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
25141         LDKChannelReestablish this_ptr_conv;
25142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25143         this_ptr_conv.is_owned = false;
25144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25145         int8_tArray ret_arr = init_int8_tArray(32);
25146         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
25147         return ret_arr;
25148 }
25149
25150 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25151         LDKChannelReestablish this_ptr_conv;
25152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25153         this_ptr_conv.is_owned = false;
25154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25155         LDKThirtyTwoBytes val_ref;
25156         CHECK(val->arr_len == 32);
25157         memcpy(val_ref.data, val->elems, 32);
25158         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
25159 }
25160
25161 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
25162         LDKChannelReestablish this_ptr_conv;
25163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25164         this_ptr_conv.is_owned = false;
25165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25166         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
25167         return ret_val;
25168 }
25169
25170 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) {
25171         LDKChannelReestablish this_ptr_conv;
25172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25173         this_ptr_conv.is_owned = false;
25174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25175         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
25176 }
25177
25178 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
25179         LDKChannelReestablish this_ptr_conv;
25180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25181         this_ptr_conv.is_owned = false;
25182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25183         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
25184         return ret_val;
25185 }
25186
25187 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) {
25188         LDKChannelReestablish this_ptr_conv;
25189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25190         this_ptr_conv.is_owned = false;
25191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25192         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
25193 }
25194
25195 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
25196         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
25197 uint64_t ret_ref = 0;
25198 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25199 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25200 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25201 ret_ref = (uint64_t)ret_var.inner;
25202 if (ret_var.is_owned) {
25203         ret_ref |= 1;
25204 }
25205         return ret_ref;
25206 }
25207 int64_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
25208         LDKChannelReestablish arg_conv;
25209         arg_conv.inner = (void*)(arg & (~1));
25210         arg_conv.is_owned = false;
25211         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25212         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
25213         return ret_val;
25214 }
25215
25216 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
25217         LDKChannelReestablish orig_conv;
25218         orig_conv.inner = (void*)(orig & (~1));
25219         orig_conv.is_owned = false;
25220         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25221         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
25222         uint64_t ret_ref = 0;
25223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25226         ret_ref = (uint64_t)ret_var.inner;
25227         if (ret_var.is_owned) {
25228                 ret_ref |= 1;
25229         }
25230         return ret_ref;
25231 }
25232
25233 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
25234         LDKAnnouncementSignatures this_obj_conv;
25235         this_obj_conv.inner = (void*)(this_obj & (~1));
25236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25238         AnnouncementSignatures_free(this_obj_conv);
25239 }
25240
25241 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
25242         LDKAnnouncementSignatures this_ptr_conv;
25243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25244         this_ptr_conv.is_owned = false;
25245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25246         int8_tArray ret_arr = init_int8_tArray(32);
25247         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
25248         return ret_arr;
25249 }
25250
25251 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25252         LDKAnnouncementSignatures this_ptr_conv;
25253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25254         this_ptr_conv.is_owned = false;
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25256         LDKThirtyTwoBytes val_ref;
25257         CHECK(val->arr_len == 32);
25258         memcpy(val_ref.data, val->elems, 32);
25259         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
25260 }
25261
25262 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
25263         LDKAnnouncementSignatures this_ptr_conv;
25264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25265         this_ptr_conv.is_owned = false;
25266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25267         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
25268         return ret_val;
25269 }
25270
25271 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25272         LDKAnnouncementSignatures this_ptr_conv;
25273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25274         this_ptr_conv.is_owned = false;
25275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25276         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
25277 }
25278
25279 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
25280         LDKAnnouncementSignatures this_ptr_conv;
25281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25282         this_ptr_conv.is_owned = false;
25283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25284         int8_tArray ret_arr = init_int8_tArray(64);
25285         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
25286         return ret_arr;
25287 }
25288
25289 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
25290         LDKAnnouncementSignatures this_ptr_conv;
25291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25292         this_ptr_conv.is_owned = false;
25293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25294         LDKSignature val_ref;
25295         CHECK(val->arr_len == 64);
25296         memcpy(val_ref.compact_form, val->elems, 64);
25297         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
25298 }
25299
25300 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
25301         LDKAnnouncementSignatures this_ptr_conv;
25302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25303         this_ptr_conv.is_owned = false;
25304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25305         int8_tArray ret_arr = init_int8_tArray(64);
25306         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
25307         return ret_arr;
25308 }
25309
25310 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
25311         LDKAnnouncementSignatures this_ptr_conv;
25312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25313         this_ptr_conv.is_owned = false;
25314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25315         LDKSignature val_ref;
25316         CHECK(val->arr_len == 64);
25317         memcpy(val_ref.compact_form, val->elems, 64);
25318         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
25319 }
25320
25321 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) {
25322         LDKThirtyTwoBytes channel_id_arg_ref;
25323         CHECK(channel_id_arg->arr_len == 32);
25324         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32);
25325         LDKSignature node_signature_arg_ref;
25326         CHECK(node_signature_arg->arr_len == 64);
25327         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64);
25328         LDKSignature bitcoin_signature_arg_ref;
25329         CHECK(bitcoin_signature_arg->arr_len == 64);
25330         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64);
25331         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
25332         uint64_t ret_ref = 0;
25333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25336         ret_ref = (uint64_t)ret_var.inner;
25337         if (ret_var.is_owned) {
25338                 ret_ref |= 1;
25339         }
25340         return ret_ref;
25341 }
25342
25343 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
25344         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
25345 uint64_t ret_ref = 0;
25346 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25347 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
25350 if (ret_var.is_owned) {
25351         ret_ref |= 1;
25352 }
25353         return ret_ref;
25354 }
25355 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
25356         LDKAnnouncementSignatures arg_conv;
25357         arg_conv.inner = (void*)(arg & (~1));
25358         arg_conv.is_owned = false;
25359         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25360         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
25361         return ret_val;
25362 }
25363
25364 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
25365         LDKAnnouncementSignatures orig_conv;
25366         orig_conv.inner = (void*)(orig & (~1));
25367         orig_conv.is_owned = false;
25368         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25369         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
25370         uint64_t ret_ref = 0;
25371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25374         ret_ref = (uint64_t)ret_var.inner;
25375         if (ret_var.is_owned) {
25376                 ret_ref |= 1;
25377         }
25378         return ret_ref;
25379 }
25380
25381 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
25382         if ((this_ptr & 1) != 0) return;
25383         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25384         CHECK_ACCESS(this_ptr_ptr);
25385         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
25386         FREE((void*)this_ptr);
25387         NetAddress_free(this_ptr_conv);
25388 }
25389
25390 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
25391         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25392         *ret_copy = NetAddress_clone(arg);
25393 uint64_t ret_ref = (uint64_t)ret_copy;
25394         return ret_ref;
25395 }
25396 int64_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
25397         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
25398         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
25399         return ret_val;
25400 }
25401
25402 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
25403         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
25404         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25405         *ret_copy = NetAddress_clone(orig_conv);
25406         uint64_t ret_ref = (uint64_t)ret_copy;
25407         return ret_ref;
25408 }
25409
25410 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
25411         LDKFourBytes addr_ref;
25412         CHECK(addr->arr_len == 4);
25413         memcpy(addr_ref.data, addr->elems, 4);
25414         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25415         *ret_copy = NetAddress_ipv4(addr_ref, port);
25416         uint64_t ret_ref = (uint64_t)ret_copy;
25417         return ret_ref;
25418 }
25419
25420 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
25421         LDKSixteenBytes addr_ref;
25422         CHECK(addr->arr_len == 16);
25423         memcpy(addr_ref.data, addr->elems, 16);
25424         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25425         *ret_copy = NetAddress_ipv6(addr_ref, port);
25426         uint64_t ret_ref = (uint64_t)ret_copy;
25427         return ret_ref;
25428 }
25429
25430 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
25431         LDKTwelveBytes a_ref;
25432         CHECK(a->arr_len == 12);
25433         memcpy(a_ref.data, a->elems, 12);
25434         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25435         *ret_copy = NetAddress_onion_v2(a_ref);
25436         uint64_t ret_ref = (uint64_t)ret_copy;
25437         return ret_ref;
25438 }
25439
25440 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) {
25441         LDKThirtyTwoBytes ed25519_pubkey_ref;
25442         CHECK(ed25519_pubkey->arr_len == 32);
25443         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32);
25444         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25445         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
25446         uint64_t ret_ref = (uint64_t)ret_copy;
25447         return ret_ref;
25448 }
25449
25450 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
25451         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
25452         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
25453         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
25454         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25455         CVec_u8Z_free(ret_var);
25456         return ret_arr;
25457 }
25458
25459 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
25460         LDKu8slice ser_ref;
25461         ser_ref.datalen = ser->arr_len;
25462         ser_ref.data = ser->elems;
25463         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
25464         *ret_conv = NetAddress_read(ser_ref);
25465         return (uint64_t)ret_conv;
25466 }
25467
25468 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
25469         LDKUnsignedNodeAnnouncement this_obj_conv;
25470         this_obj_conv.inner = (void*)(this_obj & (~1));
25471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25473         UnsignedNodeAnnouncement_free(this_obj_conv);
25474 }
25475
25476 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
25477         LDKUnsignedNodeAnnouncement this_ptr_conv;
25478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25479         this_ptr_conv.is_owned = false;
25480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25481         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
25482         uint64_t ret_ref = 0;
25483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25486         ret_ref = (uint64_t)ret_var.inner;
25487         if (ret_var.is_owned) {
25488                 ret_ref |= 1;
25489         }
25490         return ret_ref;
25491 }
25492
25493 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25494         LDKUnsignedNodeAnnouncement this_ptr_conv;
25495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25496         this_ptr_conv.is_owned = false;
25497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25498         LDKNodeFeatures val_conv;
25499         val_conv.inner = (void*)(val & (~1));
25500         val_conv.is_owned = (val & 1) || (val == 0);
25501         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25502         val_conv = NodeFeatures_clone(&val_conv);
25503         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
25504 }
25505
25506 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
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         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
25512         return ret_val;
25513 }
25514
25515 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
25516         LDKUnsignedNodeAnnouncement this_ptr_conv;
25517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25518         this_ptr_conv.is_owned = false;
25519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25520         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
25521 }
25522
25523 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
25524         LDKUnsignedNodeAnnouncement this_ptr_conv;
25525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25526         this_ptr_conv.is_owned = false;
25527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25528         int8_tArray ret_arr = init_int8_tArray(33);
25529         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
25530         return ret_arr;
25531 }
25532
25533 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
25534         LDKUnsignedNodeAnnouncement this_ptr_conv;
25535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25536         this_ptr_conv.is_owned = false;
25537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25538         LDKPublicKey val_ref;
25539         CHECK(val->arr_len == 33);
25540         memcpy(val_ref.compressed_form, val->elems, 33);
25541         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
25542 }
25543
25544 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
25545         LDKUnsignedNodeAnnouncement this_ptr_conv;
25546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25547         this_ptr_conv.is_owned = false;
25548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25549         int8_tArray ret_arr = init_int8_tArray(3);
25550         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
25551         return ret_arr;
25552 }
25553
25554 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
25555         LDKUnsignedNodeAnnouncement this_ptr_conv;
25556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25557         this_ptr_conv.is_owned = false;
25558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25559         LDKThreeBytes val_ref;
25560         CHECK(val->arr_len == 3);
25561         memcpy(val_ref.data, val->elems, 3);
25562         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
25563 }
25564
25565 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
25566         LDKUnsignedNodeAnnouncement this_ptr_conv;
25567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25568         this_ptr_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25570         int8_tArray ret_arr = init_int8_tArray(32);
25571         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
25572         return ret_arr;
25573 }
25574
25575 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
25576         LDKUnsignedNodeAnnouncement this_ptr_conv;
25577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25578         this_ptr_conv.is_owned = false;
25579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25580         LDKThirtyTwoBytes val_ref;
25581         CHECK(val->arr_len == 32);
25582         memcpy(val_ref.data, val->elems, 32);
25583         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
25584 }
25585
25586 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
25587         LDKUnsignedNodeAnnouncement this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         LDKCVec_NetAddressZ val_constr;
25592         val_constr.datalen = val->arr_len;
25593         if (val_constr.datalen > 0)
25594                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25595         else
25596                 val_constr.data = NULL;
25597         uint32_t* val_vals = val->elems;
25598         for (size_t m = 0; m < val_constr.datalen; m++) {
25599                 uint32_t val_conv_12 = val_vals[m];
25600                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
25601                 CHECK_ACCESS(val_conv_12_ptr);
25602                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
25603                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25604                 val_constr.data[m] = val_conv_12_conv;
25605         }
25606         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
25607 }
25608
25609 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
25610         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
25611 uint64_t ret_ref = 0;
25612 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25613 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25615 ret_ref = (uint64_t)ret_var.inner;
25616 if (ret_var.is_owned) {
25617         ret_ref |= 1;
25618 }
25619         return ret_ref;
25620 }
25621 int64_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
25622         LDKUnsignedNodeAnnouncement arg_conv;
25623         arg_conv.inner = (void*)(arg & (~1));
25624         arg_conv.is_owned = false;
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25626         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
25627         return ret_val;
25628 }
25629
25630 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
25631         LDKUnsignedNodeAnnouncement orig_conv;
25632         orig_conv.inner = (void*)(orig & (~1));
25633         orig_conv.is_owned = false;
25634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25635         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
25636         uint64_t ret_ref = 0;
25637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25640         ret_ref = (uint64_t)ret_var.inner;
25641         if (ret_var.is_owned) {
25642                 ret_ref |= 1;
25643         }
25644         return ret_ref;
25645 }
25646
25647 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
25648         LDKNodeAnnouncement this_obj_conv;
25649         this_obj_conv.inner = (void*)(this_obj & (~1));
25650         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25652         NodeAnnouncement_free(this_obj_conv);
25653 }
25654
25655 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
25656         LDKNodeAnnouncement this_ptr_conv;
25657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25658         this_ptr_conv.is_owned = false;
25659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25660         int8_tArray ret_arr = init_int8_tArray(64);
25661         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
25662         return ret_arr;
25663 }
25664
25665 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
25666         LDKNodeAnnouncement this_ptr_conv;
25667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25668         this_ptr_conv.is_owned = false;
25669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25670         LDKSignature val_ref;
25671         CHECK(val->arr_len == 64);
25672         memcpy(val_ref.compact_form, val->elems, 64);
25673         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
25674 }
25675
25676 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
25677         LDKNodeAnnouncement this_ptr_conv;
25678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25679         this_ptr_conv.is_owned = false;
25680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25681         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
25682         uint64_t ret_ref = 0;
25683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25686         ret_ref = (uint64_t)ret_var.inner;
25687         if (ret_var.is_owned) {
25688                 ret_ref |= 1;
25689         }
25690         return ret_ref;
25691 }
25692
25693 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25694         LDKNodeAnnouncement this_ptr_conv;
25695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25696         this_ptr_conv.is_owned = false;
25697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25698         LDKUnsignedNodeAnnouncement val_conv;
25699         val_conv.inner = (void*)(val & (~1));
25700         val_conv.is_owned = (val & 1) || (val == 0);
25701         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25702         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
25703         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
25704 }
25705
25706 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
25707         LDKSignature signature_arg_ref;
25708         CHECK(signature_arg->arr_len == 64);
25709         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
25710         LDKUnsignedNodeAnnouncement contents_arg_conv;
25711         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25712         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25714         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
25715         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
25716         uint64_t ret_ref = 0;
25717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25720         ret_ref = (uint64_t)ret_var.inner;
25721         if (ret_var.is_owned) {
25722                 ret_ref |= 1;
25723         }
25724         return ret_ref;
25725 }
25726
25727 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
25728         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
25729 uint64_t ret_ref = 0;
25730 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25731 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
25734 if (ret_var.is_owned) {
25735         ret_ref |= 1;
25736 }
25737         return ret_ref;
25738 }
25739 int64_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
25740         LDKNodeAnnouncement arg_conv;
25741         arg_conv.inner = (void*)(arg & (~1));
25742         arg_conv.is_owned = false;
25743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25744         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
25745         return ret_val;
25746 }
25747
25748 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
25749         LDKNodeAnnouncement orig_conv;
25750         orig_conv.inner = (void*)(orig & (~1));
25751         orig_conv.is_owned = false;
25752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25753         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
25754         uint64_t ret_ref = 0;
25755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25758         ret_ref = (uint64_t)ret_var.inner;
25759         if (ret_var.is_owned) {
25760                 ret_ref |= 1;
25761         }
25762         return ret_ref;
25763 }
25764
25765 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
25766         LDKUnsignedChannelAnnouncement this_obj_conv;
25767         this_obj_conv.inner = (void*)(this_obj & (~1));
25768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25770         UnsignedChannelAnnouncement_free(this_obj_conv);
25771 }
25772
25773 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
25774         LDKUnsignedChannelAnnouncement this_ptr_conv;
25775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25776         this_ptr_conv.is_owned = false;
25777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25778         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
25779         uint64_t ret_ref = 0;
25780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25783         ret_ref = (uint64_t)ret_var.inner;
25784         if (ret_var.is_owned) {
25785                 ret_ref |= 1;
25786         }
25787         return ret_ref;
25788 }
25789
25790 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25791         LDKUnsignedChannelAnnouncement this_ptr_conv;
25792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25793         this_ptr_conv.is_owned = false;
25794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25795         LDKChannelFeatures val_conv;
25796         val_conv.inner = (void*)(val & (~1));
25797         val_conv.is_owned = (val & 1) || (val == 0);
25798         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25799         val_conv = ChannelFeatures_clone(&val_conv);
25800         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
25801 }
25802
25803 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(32);
25809         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
25810         return ret_arr;
25811 }
25812
25813 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25814         LDKUnsignedChannelAnnouncement this_ptr_conv;
25815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25816         this_ptr_conv.is_owned = false;
25817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25818         LDKThirtyTwoBytes val_ref;
25819         CHECK(val->arr_len == 32);
25820         memcpy(val_ref.data, val->elems, 32);
25821         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
25822 }
25823
25824 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
25825         LDKUnsignedChannelAnnouncement this_ptr_conv;
25826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25827         this_ptr_conv.is_owned = false;
25828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25829         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
25830         return ret_val;
25831 }
25832
25833 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25834         LDKUnsignedChannelAnnouncement this_ptr_conv;
25835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25836         this_ptr_conv.is_owned = false;
25837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25838         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
25839 }
25840
25841 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
25842         LDKUnsignedChannelAnnouncement this_ptr_conv;
25843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25844         this_ptr_conv.is_owned = false;
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25846         int8_tArray ret_arr = init_int8_tArray(33);
25847         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
25848         return ret_arr;
25849 }
25850
25851 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
25852         LDKUnsignedChannelAnnouncement this_ptr_conv;
25853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25854         this_ptr_conv.is_owned = false;
25855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25856         LDKPublicKey val_ref;
25857         CHECK(val->arr_len == 33);
25858         memcpy(val_ref.compressed_form, val->elems, 33);
25859         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
25860 }
25861
25862 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
25863         LDKUnsignedChannelAnnouncement this_ptr_conv;
25864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25865         this_ptr_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25867         int8_tArray ret_arr = init_int8_tArray(33);
25868         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
25869         return ret_arr;
25870 }
25871
25872 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
25873         LDKUnsignedChannelAnnouncement this_ptr_conv;
25874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25875         this_ptr_conv.is_owned = false;
25876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25877         LDKPublicKey val_ref;
25878         CHECK(val->arr_len == 33);
25879         memcpy(val_ref.compressed_form, val->elems, 33);
25880         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
25881 }
25882
25883 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
25884         LDKUnsignedChannelAnnouncement this_ptr_conv;
25885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25886         this_ptr_conv.is_owned = false;
25887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25888         int8_tArray ret_arr = init_int8_tArray(33);
25889         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
25890         return ret_arr;
25891 }
25892
25893 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
25894         LDKUnsignedChannelAnnouncement this_ptr_conv;
25895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25896         this_ptr_conv.is_owned = false;
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25898         LDKPublicKey val_ref;
25899         CHECK(val->arr_len == 33);
25900         memcpy(val_ref.compressed_form, val->elems, 33);
25901         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
25902 }
25903
25904 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
25905         LDKUnsignedChannelAnnouncement this_ptr_conv;
25906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25907         this_ptr_conv.is_owned = false;
25908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25909         int8_tArray ret_arr = init_int8_tArray(33);
25910         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
25911         return ret_arr;
25912 }
25913
25914 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
25915         LDKUnsignedChannelAnnouncement this_ptr_conv;
25916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25917         this_ptr_conv.is_owned = false;
25918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25919         LDKPublicKey val_ref;
25920         CHECK(val->arr_len == 33);
25921         memcpy(val_ref.compressed_form, val->elems, 33);
25922         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
25923 }
25924
25925 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
25926         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
25927 uint64_t ret_ref = 0;
25928 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25929 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25930 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25931 ret_ref = (uint64_t)ret_var.inner;
25932 if (ret_var.is_owned) {
25933         ret_ref |= 1;
25934 }
25935         return ret_ref;
25936 }
25937 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
25938         LDKUnsignedChannelAnnouncement arg_conv;
25939         arg_conv.inner = (void*)(arg & (~1));
25940         arg_conv.is_owned = false;
25941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25942         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
25943         return ret_val;
25944 }
25945
25946 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
25947         LDKUnsignedChannelAnnouncement orig_conv;
25948         orig_conv.inner = (void*)(orig & (~1));
25949         orig_conv.is_owned = false;
25950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25951         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
25952         uint64_t ret_ref = 0;
25953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25956         ret_ref = (uint64_t)ret_var.inner;
25957         if (ret_var.is_owned) {
25958                 ret_ref |= 1;
25959         }
25960         return ret_ref;
25961 }
25962
25963 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
25964         LDKChannelAnnouncement this_obj_conv;
25965         this_obj_conv.inner = (void*)(this_obj & (~1));
25966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25968         ChannelAnnouncement_free(this_obj_conv);
25969 }
25970
25971 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
25972         LDKChannelAnnouncement this_ptr_conv;
25973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25974         this_ptr_conv.is_owned = false;
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25976         int8_tArray ret_arr = init_int8_tArray(64);
25977         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
25978         return ret_arr;
25979 }
25980
25981 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
25982         LDKChannelAnnouncement this_ptr_conv;
25983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25984         this_ptr_conv.is_owned = false;
25985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25986         LDKSignature val_ref;
25987         CHECK(val->arr_len == 64);
25988         memcpy(val_ref.compact_form, val->elems, 64);
25989         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
25990 }
25991
25992 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
25993         LDKChannelAnnouncement this_ptr_conv;
25994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25995         this_ptr_conv.is_owned = false;
25996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25997         int8_tArray ret_arr = init_int8_tArray(64);
25998         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
25999         return ret_arr;
26000 }
26001
26002 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
26003         LDKChannelAnnouncement this_ptr_conv;
26004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26005         this_ptr_conv.is_owned = false;
26006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26007         LDKSignature val_ref;
26008         CHECK(val->arr_len == 64);
26009         memcpy(val_ref.compact_form, val->elems, 64);
26010         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
26011 }
26012
26013 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
26014         LDKChannelAnnouncement this_ptr_conv;
26015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26016         this_ptr_conv.is_owned = false;
26017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26018         int8_tArray ret_arr = init_int8_tArray(64);
26019         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
26020         return ret_arr;
26021 }
26022
26023 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
26024         LDKChannelAnnouncement this_ptr_conv;
26025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26026         this_ptr_conv.is_owned = false;
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26028         LDKSignature val_ref;
26029         CHECK(val->arr_len == 64);
26030         memcpy(val_ref.compact_form, val->elems, 64);
26031         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
26032 }
26033
26034 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
26035         LDKChannelAnnouncement this_ptr_conv;
26036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26037         this_ptr_conv.is_owned = false;
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26039         int8_tArray ret_arr = init_int8_tArray(64);
26040         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
26041         return ret_arr;
26042 }
26043
26044 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
26045         LDKChannelAnnouncement this_ptr_conv;
26046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26047         this_ptr_conv.is_owned = false;
26048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26049         LDKSignature val_ref;
26050         CHECK(val->arr_len == 64);
26051         memcpy(val_ref.compact_form, val->elems, 64);
26052         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
26053 }
26054
26055 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
26056         LDKChannelAnnouncement this_ptr_conv;
26057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26058         this_ptr_conv.is_owned = false;
26059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26060         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
26061         uint64_t ret_ref = 0;
26062         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26063         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26065         ret_ref = (uint64_t)ret_var.inner;
26066         if (ret_var.is_owned) {
26067                 ret_ref |= 1;
26068         }
26069         return ret_ref;
26070 }
26071
26072 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
26073         LDKChannelAnnouncement this_ptr_conv;
26074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26075         this_ptr_conv.is_owned = false;
26076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26077         LDKUnsignedChannelAnnouncement val_conv;
26078         val_conv.inner = (void*)(val & (~1));
26079         val_conv.is_owned = (val & 1) || (val == 0);
26080         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26081         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
26082         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
26083 }
26084
26085 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) {
26086         LDKSignature node_signature_1_arg_ref;
26087         CHECK(node_signature_1_arg->arr_len == 64);
26088         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64);
26089         LDKSignature node_signature_2_arg_ref;
26090         CHECK(node_signature_2_arg->arr_len == 64);
26091         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64);
26092         LDKSignature bitcoin_signature_1_arg_ref;
26093         CHECK(bitcoin_signature_1_arg->arr_len == 64);
26094         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64);
26095         LDKSignature bitcoin_signature_2_arg_ref;
26096         CHECK(bitcoin_signature_2_arg->arr_len == 64);
26097         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64);
26098         LDKUnsignedChannelAnnouncement contents_arg_conv;
26099         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26100         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26101         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26102         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
26103         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);
26104         uint64_t ret_ref = 0;
26105         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26106         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26108         ret_ref = (uint64_t)ret_var.inner;
26109         if (ret_var.is_owned) {
26110                 ret_ref |= 1;
26111         }
26112         return ret_ref;
26113 }
26114
26115 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
26116         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
26117 uint64_t ret_ref = 0;
26118 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26119 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26122 if (ret_var.is_owned) {
26123         ret_ref |= 1;
26124 }
26125         return ret_ref;
26126 }
26127 int64_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
26128         LDKChannelAnnouncement arg_conv;
26129         arg_conv.inner = (void*)(arg & (~1));
26130         arg_conv.is_owned = false;
26131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26132         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
26133         return ret_val;
26134 }
26135
26136 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
26137         LDKChannelAnnouncement orig_conv;
26138         orig_conv.inner = (void*)(orig & (~1));
26139         orig_conv.is_owned = false;
26140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26141         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
26142         uint64_t ret_ref = 0;
26143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26146         ret_ref = (uint64_t)ret_var.inner;
26147         if (ret_var.is_owned) {
26148                 ret_ref |= 1;
26149         }
26150         return ret_ref;
26151 }
26152
26153 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
26154         LDKUnsignedChannelUpdate this_obj_conv;
26155         this_obj_conv.inner = (void*)(this_obj & (~1));
26156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26158         UnsignedChannelUpdate_free(this_obj_conv);
26159 }
26160
26161 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
26162         LDKUnsignedChannelUpdate this_ptr_conv;
26163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26164         this_ptr_conv.is_owned = false;
26165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26166         int8_tArray ret_arr = init_int8_tArray(32);
26167         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
26168         return ret_arr;
26169 }
26170
26171 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26172         LDKUnsignedChannelUpdate this_ptr_conv;
26173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26174         this_ptr_conv.is_owned = false;
26175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26176         LDKThirtyTwoBytes val_ref;
26177         CHECK(val->arr_len == 32);
26178         memcpy(val_ref.data, val->elems, 32);
26179         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
26180 }
26181
26182 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
26183         LDKUnsignedChannelUpdate this_ptr_conv;
26184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26185         this_ptr_conv.is_owned = false;
26186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26187         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
26188         return ret_val;
26189 }
26190
26191 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
26192         LDKUnsignedChannelUpdate this_ptr_conv;
26193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26194         this_ptr_conv.is_owned = false;
26195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26196         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
26197 }
26198
26199 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
26200         LDKUnsignedChannelUpdate this_ptr_conv;
26201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26202         this_ptr_conv.is_owned = false;
26203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26204         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
26205         return ret_val;
26206 }
26207
26208 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
26209         LDKUnsignedChannelUpdate this_ptr_conv;
26210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26211         this_ptr_conv.is_owned = false;
26212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26213         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
26214 }
26215
26216 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
26217         LDKUnsignedChannelUpdate this_ptr_conv;
26218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26219         this_ptr_conv.is_owned = false;
26220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26221         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
26222         return ret_val;
26223 }
26224
26225 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
26226         LDKUnsignedChannelUpdate this_ptr_conv;
26227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26228         this_ptr_conv.is_owned = false;
26229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26230         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
26231 }
26232
26233 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
26234         LDKUnsignedChannelUpdate this_ptr_conv;
26235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26236         this_ptr_conv.is_owned = false;
26237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26238         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
26239         return ret_val;
26240 }
26241
26242 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
26243         LDKUnsignedChannelUpdate this_ptr_conv;
26244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26245         this_ptr_conv.is_owned = false;
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26247         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
26248 }
26249
26250 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
26251         LDKUnsignedChannelUpdate this_ptr_conv;
26252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26253         this_ptr_conv.is_owned = false;
26254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26255         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
26256         return ret_val;
26257 }
26258
26259 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26260         LDKUnsignedChannelUpdate this_ptr_conv;
26261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26262         this_ptr_conv.is_owned = false;
26263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26264         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
26265 }
26266
26267 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
26268         LDKUnsignedChannelUpdate this_ptr_conv;
26269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26270         this_ptr_conv.is_owned = false;
26271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26272         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
26273         return ret_val;
26274 }
26275
26276 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
26277         LDKUnsignedChannelUpdate this_ptr_conv;
26278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26279         this_ptr_conv.is_owned = false;
26280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26281         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
26282 }
26283
26284 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
26285         LDKUnsignedChannelUpdate this_ptr_conv;
26286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26287         this_ptr_conv.is_owned = false;
26288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26289         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
26290         return ret_val;
26291 }
26292
26293 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
26294         LDKUnsignedChannelUpdate this_ptr_conv;
26295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26296         this_ptr_conv.is_owned = false;
26297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26298         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
26299 }
26300
26301 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
26302         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
26303 uint64_t ret_ref = 0;
26304 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26305 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26306 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26307 ret_ref = (uint64_t)ret_var.inner;
26308 if (ret_var.is_owned) {
26309         ret_ref |= 1;
26310 }
26311         return ret_ref;
26312 }
26313 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
26314         LDKUnsignedChannelUpdate arg_conv;
26315         arg_conv.inner = (void*)(arg & (~1));
26316         arg_conv.is_owned = false;
26317         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26318         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
26319         return ret_val;
26320 }
26321
26322 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
26323         LDKUnsignedChannelUpdate orig_conv;
26324         orig_conv.inner = (void*)(orig & (~1));
26325         orig_conv.is_owned = false;
26326         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26327         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
26328         uint64_t ret_ref = 0;
26329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26332         ret_ref = (uint64_t)ret_var.inner;
26333         if (ret_var.is_owned) {
26334                 ret_ref |= 1;
26335         }
26336         return ret_ref;
26337 }
26338
26339 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
26340         LDKChannelUpdate this_obj_conv;
26341         this_obj_conv.inner = (void*)(this_obj & (~1));
26342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26344         ChannelUpdate_free(this_obj_conv);
26345 }
26346
26347 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
26348         LDKChannelUpdate this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         int8_tArray ret_arr = init_int8_tArray(64);
26353         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
26354         return ret_arr;
26355 }
26356
26357 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
26358         LDKChannelUpdate this_ptr_conv;
26359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26360         this_ptr_conv.is_owned = false;
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         LDKSignature val_ref;
26363         CHECK(val->arr_len == 64);
26364         memcpy(val_ref.compact_form, val->elems, 64);
26365         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
26366 }
26367
26368 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
26369         LDKChannelUpdate this_ptr_conv;
26370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26371         this_ptr_conv.is_owned = false;
26372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26373         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
26374         uint64_t ret_ref = 0;
26375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26378         ret_ref = (uint64_t)ret_var.inner;
26379         if (ret_var.is_owned) {
26380                 ret_ref |= 1;
26381         }
26382         return ret_ref;
26383 }
26384
26385 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
26386         LDKChannelUpdate this_ptr_conv;
26387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26388         this_ptr_conv.is_owned = false;
26389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26390         LDKUnsignedChannelUpdate val_conv;
26391         val_conv.inner = (void*)(val & (~1));
26392         val_conv.is_owned = (val & 1) || (val == 0);
26393         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26394         val_conv = UnsignedChannelUpdate_clone(&val_conv);
26395         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
26396 }
26397
26398 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
26399         LDKSignature signature_arg_ref;
26400         CHECK(signature_arg->arr_len == 64);
26401         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64);
26402         LDKUnsignedChannelUpdate contents_arg_conv;
26403         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26404         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26405         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26406         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
26407         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
26408         uint64_t ret_ref = 0;
26409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26412         ret_ref = (uint64_t)ret_var.inner;
26413         if (ret_var.is_owned) {
26414                 ret_ref |= 1;
26415         }
26416         return ret_ref;
26417 }
26418
26419 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
26420         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
26421 uint64_t ret_ref = 0;
26422 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26423 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26426 if (ret_var.is_owned) {
26427         ret_ref |= 1;
26428 }
26429         return ret_ref;
26430 }
26431 int64_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
26432         LDKChannelUpdate arg_conv;
26433         arg_conv.inner = (void*)(arg & (~1));
26434         arg_conv.is_owned = false;
26435         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26436         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
26437         return ret_val;
26438 }
26439
26440 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
26441         LDKChannelUpdate orig_conv;
26442         orig_conv.inner = (void*)(orig & (~1));
26443         orig_conv.is_owned = false;
26444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26445         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
26446         uint64_t ret_ref = 0;
26447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26450         ret_ref = (uint64_t)ret_var.inner;
26451         if (ret_var.is_owned) {
26452                 ret_ref |= 1;
26453         }
26454         return ret_ref;
26455 }
26456
26457 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
26458         LDKQueryChannelRange this_obj_conv;
26459         this_obj_conv.inner = (void*)(this_obj & (~1));
26460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26462         QueryChannelRange_free(this_obj_conv);
26463 }
26464
26465 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
26466         LDKQueryChannelRange this_ptr_conv;
26467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26468         this_ptr_conv.is_owned = false;
26469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26470         int8_tArray ret_arr = init_int8_tArray(32);
26471         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
26472         return ret_arr;
26473 }
26474
26475 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26476         LDKQueryChannelRange this_ptr_conv;
26477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26478         this_ptr_conv.is_owned = false;
26479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26480         LDKThirtyTwoBytes val_ref;
26481         CHECK(val->arr_len == 32);
26482         memcpy(val_ref.data, val->elems, 32);
26483         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26484 }
26485
26486 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
26487         LDKQueryChannelRange this_ptr_conv;
26488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26489         this_ptr_conv.is_owned = false;
26490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26491         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
26492         return ret_val;
26493 }
26494
26495 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26496         LDKQueryChannelRange this_ptr_conv;
26497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26498         this_ptr_conv.is_owned = false;
26499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26500         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
26501 }
26502
26503 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26504         LDKQueryChannelRange this_ptr_conv;
26505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26506         this_ptr_conv.is_owned = false;
26507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26508         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
26509         return ret_val;
26510 }
26511
26512 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26513         LDKQueryChannelRange this_ptr_conv;
26514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26515         this_ptr_conv.is_owned = false;
26516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26517         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26518 }
26519
26520 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) {
26521         LDKThirtyTwoBytes chain_hash_arg_ref;
26522         CHECK(chain_hash_arg->arr_len == 32);
26523         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32);
26524         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
26525         uint64_t ret_ref = 0;
26526         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26527         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26529         ret_ref = (uint64_t)ret_var.inner;
26530         if (ret_var.is_owned) {
26531                 ret_ref |= 1;
26532         }
26533         return ret_ref;
26534 }
26535
26536 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
26537         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
26538 uint64_t ret_ref = 0;
26539 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26540 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26543 if (ret_var.is_owned) {
26544         ret_ref |= 1;
26545 }
26546         return ret_ref;
26547 }
26548 int64_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
26549         LDKQueryChannelRange arg_conv;
26550         arg_conv.inner = (void*)(arg & (~1));
26551         arg_conv.is_owned = false;
26552         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26553         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
26554         return ret_val;
26555 }
26556
26557 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
26558         LDKQueryChannelRange orig_conv;
26559         orig_conv.inner = (void*)(orig & (~1));
26560         orig_conv.is_owned = false;
26561         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26562         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
26563         uint64_t ret_ref = 0;
26564         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26565         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26567         ret_ref = (uint64_t)ret_var.inner;
26568         if (ret_var.is_owned) {
26569                 ret_ref |= 1;
26570         }
26571         return ret_ref;
26572 }
26573
26574 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
26575         LDKReplyChannelRange this_obj_conv;
26576         this_obj_conv.inner = (void*)(this_obj & (~1));
26577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26579         ReplyChannelRange_free(this_obj_conv);
26580 }
26581
26582 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
26583         LDKReplyChannelRange this_ptr_conv;
26584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26585         this_ptr_conv.is_owned = false;
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26587         int8_tArray ret_arr = init_int8_tArray(32);
26588         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
26589         return ret_arr;
26590 }
26591
26592 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26593         LDKReplyChannelRange this_ptr_conv;
26594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26595         this_ptr_conv.is_owned = false;
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26597         LDKThirtyTwoBytes val_ref;
26598         CHECK(val->arr_len == 32);
26599         memcpy(val_ref.data, val->elems, 32);
26600         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26601 }
26602
26603 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
26604         LDKReplyChannelRange this_ptr_conv;
26605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26606         this_ptr_conv.is_owned = false;
26607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26608         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
26609         return ret_val;
26610 }
26611
26612 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26613         LDKReplyChannelRange this_ptr_conv;
26614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26615         this_ptr_conv.is_owned = false;
26616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26617         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
26618 }
26619
26620 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26621         LDKReplyChannelRange this_ptr_conv;
26622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26623         this_ptr_conv.is_owned = false;
26624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26625         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
26626         return ret_val;
26627 }
26628
26629 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26630         LDKReplyChannelRange this_ptr_conv;
26631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26632         this_ptr_conv.is_owned = false;
26633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26634         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26635 }
26636
26637 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
26638         LDKReplyChannelRange this_ptr_conv;
26639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26640         this_ptr_conv.is_owned = false;
26641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26642         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
26643         return ret_val;
26644 }
26645
26646 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
26647         LDKReplyChannelRange this_ptr_conv;
26648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26649         this_ptr_conv.is_owned = false;
26650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26651         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
26652 }
26653
26654 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26655         LDKReplyChannelRange this_ptr_conv;
26656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26657         this_ptr_conv.is_owned = false;
26658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26659         LDKCVec_u64Z val_constr;
26660         val_constr.datalen = val->arr_len;
26661         if (val_constr.datalen > 0)
26662                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26663         else
26664                 val_constr.data = NULL;
26665         int64_t* val_vals = val->elems;
26666         for (size_t i = 0; i < val_constr.datalen; i++) {
26667                 int64_t val_conv_8 = val_vals[i];
26668                 val_constr.data[i] = val_conv_8;
26669         }
26670         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
26671 }
26672
26673 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) {
26674         LDKThirtyTwoBytes chain_hash_arg_ref;
26675         CHECK(chain_hash_arg->arr_len == 32);
26676         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32);
26677         LDKCVec_u64Z short_channel_ids_arg_constr;
26678         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26679         if (short_channel_ids_arg_constr.datalen > 0)
26680                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26681         else
26682                 short_channel_ids_arg_constr.data = NULL;
26683         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
26684         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26685                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26686                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26687         }
26688         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
26689         uint64_t ret_ref = 0;
26690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26693         ret_ref = (uint64_t)ret_var.inner;
26694         if (ret_var.is_owned) {
26695                 ret_ref |= 1;
26696         }
26697         return ret_ref;
26698 }
26699
26700 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
26701         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
26702 uint64_t ret_ref = 0;
26703 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26704 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26707 if (ret_var.is_owned) {
26708         ret_ref |= 1;
26709 }
26710         return ret_ref;
26711 }
26712 int64_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
26713         LDKReplyChannelRange arg_conv;
26714         arg_conv.inner = (void*)(arg & (~1));
26715         arg_conv.is_owned = false;
26716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26717         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
26718         return ret_val;
26719 }
26720
26721 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
26722         LDKReplyChannelRange orig_conv;
26723         orig_conv.inner = (void*)(orig & (~1));
26724         orig_conv.is_owned = false;
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26726         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
26727         uint64_t ret_ref = 0;
26728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26731         ret_ref = (uint64_t)ret_var.inner;
26732         if (ret_var.is_owned) {
26733                 ret_ref |= 1;
26734         }
26735         return ret_ref;
26736 }
26737
26738 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
26739         LDKQueryShortChannelIds this_obj_conv;
26740         this_obj_conv.inner = (void*)(this_obj & (~1));
26741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26743         QueryShortChannelIds_free(this_obj_conv);
26744 }
26745
26746 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
26747         LDKQueryShortChannelIds this_ptr_conv;
26748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26749         this_ptr_conv.is_owned = false;
26750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26751         int8_tArray ret_arr = init_int8_tArray(32);
26752         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
26753         return ret_arr;
26754 }
26755
26756 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26757         LDKQueryShortChannelIds this_ptr_conv;
26758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26759         this_ptr_conv.is_owned = false;
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26761         LDKThirtyTwoBytes val_ref;
26762         CHECK(val->arr_len == 32);
26763         memcpy(val_ref.data, val->elems, 32);
26764         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
26765 }
26766
26767 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26768         LDKQueryShortChannelIds this_ptr_conv;
26769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26770         this_ptr_conv.is_owned = false;
26771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26772         LDKCVec_u64Z val_constr;
26773         val_constr.datalen = val->arr_len;
26774         if (val_constr.datalen > 0)
26775                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26776         else
26777                 val_constr.data = NULL;
26778         int64_t* val_vals = val->elems;
26779         for (size_t i = 0; i < val_constr.datalen; i++) {
26780                 int64_t val_conv_8 = val_vals[i];
26781                 val_constr.data[i] = val_conv_8;
26782         }
26783         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
26784 }
26785
26786 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
26787         LDKThirtyTwoBytes chain_hash_arg_ref;
26788         CHECK(chain_hash_arg->arr_len == 32);
26789         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32);
26790         LDKCVec_u64Z short_channel_ids_arg_constr;
26791         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26792         if (short_channel_ids_arg_constr.datalen > 0)
26793                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26794         else
26795                 short_channel_ids_arg_constr.data = NULL;
26796         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
26797         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26798                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26799                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26800         }
26801         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
26802         uint64_t ret_ref = 0;
26803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26806         ret_ref = (uint64_t)ret_var.inner;
26807         if (ret_var.is_owned) {
26808                 ret_ref |= 1;
26809         }
26810         return ret_ref;
26811 }
26812
26813 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
26814         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
26815 uint64_t ret_ref = 0;
26816 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26817 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26820 if (ret_var.is_owned) {
26821         ret_ref |= 1;
26822 }
26823         return ret_ref;
26824 }
26825 int64_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
26826         LDKQueryShortChannelIds arg_conv;
26827         arg_conv.inner = (void*)(arg & (~1));
26828         arg_conv.is_owned = false;
26829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26830         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
26831         return ret_val;
26832 }
26833
26834 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
26835         LDKQueryShortChannelIds orig_conv;
26836         orig_conv.inner = (void*)(orig & (~1));
26837         orig_conv.is_owned = false;
26838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26839         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
26840         uint64_t ret_ref = 0;
26841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26844         ret_ref = (uint64_t)ret_var.inner;
26845         if (ret_var.is_owned) {
26846                 ret_ref |= 1;
26847         }
26848         return ret_ref;
26849 }
26850
26851 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
26852         LDKReplyShortChannelIdsEnd this_obj_conv;
26853         this_obj_conv.inner = (void*)(this_obj & (~1));
26854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26856         ReplyShortChannelIdsEnd_free(this_obj_conv);
26857 }
26858
26859 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
26860         LDKReplyShortChannelIdsEnd this_ptr_conv;
26861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26862         this_ptr_conv.is_owned = false;
26863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26864         int8_tArray ret_arr = init_int8_tArray(32);
26865         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
26866         return ret_arr;
26867 }
26868
26869 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26870         LDKReplyShortChannelIdsEnd this_ptr_conv;
26871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26872         this_ptr_conv.is_owned = false;
26873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26874         LDKThirtyTwoBytes val_ref;
26875         CHECK(val->arr_len == 32);
26876         memcpy(val_ref.data, val->elems, 32);
26877         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
26878 }
26879
26880 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
26881         LDKReplyShortChannelIdsEnd this_ptr_conv;
26882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26883         this_ptr_conv.is_owned = false;
26884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26885         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
26886         return ret_val;
26887 }
26888
26889 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
26890         LDKReplyShortChannelIdsEnd this_ptr_conv;
26891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26892         this_ptr_conv.is_owned = false;
26893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26894         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
26895 }
26896
26897 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
26898         LDKThirtyTwoBytes chain_hash_arg_ref;
26899         CHECK(chain_hash_arg->arr_len == 32);
26900         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32);
26901         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
26902         uint64_t ret_ref = 0;
26903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26906         ret_ref = (uint64_t)ret_var.inner;
26907         if (ret_var.is_owned) {
26908                 ret_ref |= 1;
26909         }
26910         return ret_ref;
26911 }
26912
26913 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
26914         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
26915 uint64_t ret_ref = 0;
26916 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26917 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
26920 if (ret_var.is_owned) {
26921         ret_ref |= 1;
26922 }
26923         return ret_ref;
26924 }
26925 int64_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
26926         LDKReplyShortChannelIdsEnd arg_conv;
26927         arg_conv.inner = (void*)(arg & (~1));
26928         arg_conv.is_owned = false;
26929         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26930         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
26931         return ret_val;
26932 }
26933
26934 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
26935         LDKReplyShortChannelIdsEnd orig_conv;
26936         orig_conv.inner = (void*)(orig & (~1));
26937         orig_conv.is_owned = false;
26938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26939         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
26940         uint64_t ret_ref = 0;
26941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26944         ret_ref = (uint64_t)ret_var.inner;
26945         if (ret_var.is_owned) {
26946                 ret_ref |= 1;
26947         }
26948         return ret_ref;
26949 }
26950
26951 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
26952         LDKGossipTimestampFilter this_obj_conv;
26953         this_obj_conv.inner = (void*)(this_obj & (~1));
26954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26956         GossipTimestampFilter_free(this_obj_conv);
26957 }
26958
26959 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
26960         LDKGossipTimestampFilter this_ptr_conv;
26961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26962         this_ptr_conv.is_owned = false;
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26964         int8_tArray ret_arr = init_int8_tArray(32);
26965         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
26966         return ret_arr;
26967 }
26968
26969 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26970         LDKGossipTimestampFilter this_ptr_conv;
26971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26972         this_ptr_conv.is_owned = false;
26973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26974         LDKThirtyTwoBytes val_ref;
26975         CHECK(val->arr_len == 32);
26976         memcpy(val_ref.data, val->elems, 32);
26977         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
26978 }
26979
26980 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
26981         LDKGossipTimestampFilter this_ptr_conv;
26982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26983         this_ptr_conv.is_owned = false;
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26985         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
26986         return ret_val;
26987 }
26988
26989 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
26990         LDKGossipTimestampFilter this_ptr_conv;
26991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26992         this_ptr_conv.is_owned = false;
26993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26994         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
26995 }
26996
26997 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
26998         LDKGossipTimestampFilter this_ptr_conv;
26999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27000         this_ptr_conv.is_owned = false;
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27002         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
27003         return ret_val;
27004 }
27005
27006 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
27007         LDKGossipTimestampFilter this_ptr_conv;
27008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27009         this_ptr_conv.is_owned = false;
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27011         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
27012 }
27013
27014 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) {
27015         LDKThirtyTwoBytes chain_hash_arg_ref;
27016         CHECK(chain_hash_arg->arr_len == 32);
27017         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32);
27018         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
27019         uint64_t ret_ref = 0;
27020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27023         ret_ref = (uint64_t)ret_var.inner;
27024         if (ret_var.is_owned) {
27025                 ret_ref |= 1;
27026         }
27027         return ret_ref;
27028 }
27029
27030 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
27031         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
27032 uint64_t ret_ref = 0;
27033 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27034 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
27037 if (ret_var.is_owned) {
27038         ret_ref |= 1;
27039 }
27040         return ret_ref;
27041 }
27042 int64_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
27043         LDKGossipTimestampFilter arg_conv;
27044         arg_conv.inner = (void*)(arg & (~1));
27045         arg_conv.is_owned = false;
27046         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27047         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
27048         return ret_val;
27049 }
27050
27051 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
27052         LDKGossipTimestampFilter orig_conv;
27053         orig_conv.inner = (void*)(orig & (~1));
27054         orig_conv.is_owned = false;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27056         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
27057         uint64_t ret_ref = 0;
27058         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27059         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27061         ret_ref = (uint64_t)ret_var.inner;
27062         if (ret_var.is_owned) {
27063                 ret_ref |= 1;
27064         }
27065         return ret_ref;
27066 }
27067
27068 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
27069         if ((this_ptr & 1) != 0) return;
27070         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27071         CHECK_ACCESS(this_ptr_ptr);
27072         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
27073         FREE((void*)this_ptr);
27074         ErrorAction_free(this_ptr_conv);
27075 }
27076
27077 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
27078         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27079         *ret_copy = ErrorAction_clone(arg);
27080 uint64_t ret_ref = (uint64_t)ret_copy;
27081         return ret_ref;
27082 }
27083 int64_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
27084         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
27085         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
27086         return ret_val;
27087 }
27088
27089 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
27090         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
27091         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27092         *ret_copy = ErrorAction_clone(orig_conv);
27093         uint64_t ret_ref = (uint64_t)ret_copy;
27094         return ret_ref;
27095 }
27096
27097 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
27098         LDKErrorMessage msg_conv;
27099         msg_conv.inner = (void*)(msg & (~1));
27100         msg_conv.is_owned = (msg & 1) || (msg == 0);
27101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27102         msg_conv = ErrorMessage_clone(&msg_conv);
27103         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27104         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
27105         uint64_t ret_ref = (uint64_t)ret_copy;
27106         return ret_ref;
27107 }
27108
27109 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
27110         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27111         *ret_copy = ErrorAction_ignore_error();
27112         uint64_t ret_ref = (uint64_t)ret_copy;
27113         return ret_ref;
27114 }
27115
27116 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
27117         LDKLevel a_conv = LDKLevel_from_js(a);
27118         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27119         *ret_copy = ErrorAction_ignore_and_log(a_conv);
27120         uint64_t ret_ref = (uint64_t)ret_copy;
27121         return ret_ref;
27122 }
27123
27124 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
27125         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27126         *ret_copy = ErrorAction_ignore_duplicate_gossip();
27127         uint64_t ret_ref = (uint64_t)ret_copy;
27128         return ret_ref;
27129 }
27130
27131 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
27132         LDKErrorMessage msg_conv;
27133         msg_conv.inner = (void*)(msg & (~1));
27134         msg_conv.is_owned = (msg & 1) || (msg == 0);
27135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27136         msg_conv = ErrorMessage_clone(&msg_conv);
27137         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27138         *ret_copy = ErrorAction_send_error_message(msg_conv);
27139         uint64_t ret_ref = (uint64_t)ret_copy;
27140         return ret_ref;
27141 }
27142
27143 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
27144         LDKLightningError this_obj_conv;
27145         this_obj_conv.inner = (void*)(this_obj & (~1));
27146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27148         LightningError_free(this_obj_conv);
27149 }
27150
27151 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
27152         LDKLightningError this_ptr_conv;
27153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27154         this_ptr_conv.is_owned = false;
27155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27156         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
27157         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27158         Str_free(ret_str);
27159         return ret_conv;
27160 }
27161
27162 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
27163         LDKLightningError this_ptr_conv;
27164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27165         this_ptr_conv.is_owned = false;
27166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27167         LDKStr val_conv = str_ref_to_owned_c(val);
27168         LightningError_set_err(&this_ptr_conv, val_conv);
27169 }
27170
27171 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
27172         LDKLightningError this_ptr_conv;
27173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27174         this_ptr_conv.is_owned = false;
27175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27176         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27177         *ret_copy = LightningError_get_action(&this_ptr_conv);
27178         uint64_t ret_ref = (uint64_t)ret_copy;
27179         return ret_ref;
27180 }
27181
27182 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
27183         LDKLightningError this_ptr_conv;
27184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27185         this_ptr_conv.is_owned = false;
27186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27187         void* val_ptr = (void*)(((uint64_t)val) & ~1);
27188         CHECK_ACCESS(val_ptr);
27189         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
27190         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
27191         LightningError_set_action(&this_ptr_conv, val_conv);
27192 }
27193
27194 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
27195         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
27196         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
27197         CHECK_ACCESS(action_arg_ptr);
27198         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
27199         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
27200         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
27201         uint64_t ret_ref = 0;
27202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27205         ret_ref = (uint64_t)ret_var.inner;
27206         if (ret_var.is_owned) {
27207                 ret_ref |= 1;
27208         }
27209         return ret_ref;
27210 }
27211
27212 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
27213         LDKLightningError ret_var = LightningError_clone(arg);
27214 uint64_t ret_ref = 0;
27215 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27216 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
27219 if (ret_var.is_owned) {
27220         ret_ref |= 1;
27221 }
27222         return ret_ref;
27223 }
27224 int64_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
27225         LDKLightningError arg_conv;
27226         arg_conv.inner = (void*)(arg & (~1));
27227         arg_conv.is_owned = false;
27228         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27229         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
27230         return ret_val;
27231 }
27232
27233 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
27234         LDKLightningError orig_conv;
27235         orig_conv.inner = (void*)(orig & (~1));
27236         orig_conv.is_owned = false;
27237         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27238         LDKLightningError ret_var = LightningError_clone(&orig_conv);
27239         uint64_t ret_ref = 0;
27240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27243         ret_ref = (uint64_t)ret_var.inner;
27244         if (ret_var.is_owned) {
27245                 ret_ref |= 1;
27246         }
27247         return ret_ref;
27248 }
27249
27250 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
27251         LDKCommitmentUpdate this_obj_conv;
27252         this_obj_conv.inner = (void*)(this_obj & (~1));
27253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27255         CommitmentUpdate_free(this_obj_conv);
27256 }
27257
27258 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
27259         LDKCommitmentUpdate this_ptr_conv;
27260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27261         this_ptr_conv.is_owned = false;
27262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27263         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
27264         uint32_tArray ret_arr = NULL;
27265         ret_arr = init_uint32_tArray(ret_var.datalen);
27266         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27267         for (size_t p = 0; p < ret_var.datalen; p++) {
27268                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
27269                 uint64_t ret_conv_15_ref = 0;
27270                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27271                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27272                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
27273                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
27274                 if (ret_conv_15_var.is_owned) {
27275                         ret_conv_15_ref |= 1;
27276                 }
27277                 ret_arr_ptr[p] = ret_conv_15_ref;
27278         }
27279         
27280         FREE(ret_var.data);
27281         return ret_arr;
27282 }
27283
27284 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
27285         LDKCommitmentUpdate this_ptr_conv;
27286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27287         this_ptr_conv.is_owned = false;
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27289         LDKCVec_UpdateAddHTLCZ val_constr;
27290         val_constr.datalen = val->arr_len;
27291         if (val_constr.datalen > 0)
27292                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27293         else
27294                 val_constr.data = NULL;
27295         uint32_t* val_vals = val->elems;
27296         for (size_t p = 0; p < val_constr.datalen; p++) {
27297                 uint32_t val_conv_15 = val_vals[p];
27298                 LDKUpdateAddHTLC val_conv_15_conv;
27299                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
27300                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
27301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
27302                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
27303                 val_constr.data[p] = val_conv_15_conv;
27304         }
27305         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
27306 }
27307
27308 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
27309         LDKCommitmentUpdate this_ptr_conv;
27310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27311         this_ptr_conv.is_owned = false;
27312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27313         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
27314         uint32_tArray ret_arr = NULL;
27315         ret_arr = init_uint32_tArray(ret_var.datalen);
27316         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27317         for (size_t t = 0; t < ret_var.datalen; t++) {
27318                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
27319                 uint64_t ret_conv_19_ref = 0;
27320                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27321                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27322                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
27323                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
27324                 if (ret_conv_19_var.is_owned) {
27325                         ret_conv_19_ref |= 1;
27326                 }
27327                 ret_arr_ptr[t] = ret_conv_19_ref;
27328         }
27329         
27330         FREE(ret_var.data);
27331         return ret_arr;
27332 }
27333
27334 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
27335         LDKCommitmentUpdate this_ptr_conv;
27336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27337         this_ptr_conv.is_owned = false;
27338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27339         LDKCVec_UpdateFulfillHTLCZ val_constr;
27340         val_constr.datalen = val->arr_len;
27341         if (val_constr.datalen > 0)
27342                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27343         else
27344                 val_constr.data = NULL;
27345         uint32_t* val_vals = val->elems;
27346         for (size_t t = 0; t < val_constr.datalen; t++) {
27347                 uint32_t val_conv_19 = val_vals[t];
27348                 LDKUpdateFulfillHTLC val_conv_19_conv;
27349                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
27350                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
27351                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
27352                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
27353                 val_constr.data[t] = val_conv_19_conv;
27354         }
27355         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
27356 }
27357
27358 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
27359         LDKCommitmentUpdate this_ptr_conv;
27360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27361         this_ptr_conv.is_owned = false;
27362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27363         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
27364         uint32_tArray ret_arr = NULL;
27365         ret_arr = init_uint32_tArray(ret_var.datalen);
27366         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27367         for (size_t q = 0; q < ret_var.datalen; q++) {
27368                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
27369                 uint64_t ret_conv_16_ref = 0;
27370                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27371                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27372                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27373                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
27374                 if (ret_conv_16_var.is_owned) {
27375                         ret_conv_16_ref |= 1;
27376                 }
27377                 ret_arr_ptr[q] = ret_conv_16_ref;
27378         }
27379         
27380         FREE(ret_var.data);
27381         return ret_arr;
27382 }
27383
27384 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
27385         LDKCommitmentUpdate this_ptr_conv;
27386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27387         this_ptr_conv.is_owned = false;
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27389         LDKCVec_UpdateFailHTLCZ val_constr;
27390         val_constr.datalen = val->arr_len;
27391         if (val_constr.datalen > 0)
27392                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27393         else
27394                 val_constr.data = NULL;
27395         uint32_t* val_vals = val->elems;
27396         for (size_t q = 0; q < val_constr.datalen; q++) {
27397                 uint32_t val_conv_16 = val_vals[q];
27398                 LDKUpdateFailHTLC val_conv_16_conv;
27399                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
27400                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
27401                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
27402                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
27403                 val_constr.data[q] = val_conv_16_conv;
27404         }
27405         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
27406 }
27407
27408 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
27409         LDKCommitmentUpdate this_ptr_conv;
27410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27411         this_ptr_conv.is_owned = false;
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27413         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
27414         uint32_tArray ret_arr = NULL;
27415         ret_arr = init_uint32_tArray(ret_var.datalen);
27416         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27417         for (size_t z = 0; z < ret_var.datalen; z++) {
27418                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
27419                 uint64_t ret_conv_25_ref = 0;
27420                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27421                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
27423                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
27424                 if (ret_conv_25_var.is_owned) {
27425                         ret_conv_25_ref |= 1;
27426                 }
27427                 ret_arr_ptr[z] = ret_conv_25_ref;
27428         }
27429         
27430         FREE(ret_var.data);
27431         return ret_arr;
27432 }
27433
27434 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) {
27435         LDKCommitmentUpdate this_ptr_conv;
27436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27437         this_ptr_conv.is_owned = false;
27438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27439         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
27440         val_constr.datalen = val->arr_len;
27441         if (val_constr.datalen > 0)
27442                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27443         else
27444                 val_constr.data = NULL;
27445         uint32_t* val_vals = val->elems;
27446         for (size_t z = 0; z < val_constr.datalen; z++) {
27447                 uint32_t val_conv_25 = val_vals[z];
27448                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
27449                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
27450                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
27451                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
27452                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
27453                 val_constr.data[z] = val_conv_25_conv;
27454         }
27455         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
27456 }
27457
27458 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
27459         LDKCommitmentUpdate this_ptr_conv;
27460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27461         this_ptr_conv.is_owned = false;
27462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27463         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
27464         uint64_t ret_ref = 0;
27465         if ((uint64_t)ret_var.inner > 4096) {
27466                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27467                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27469                 ret_ref = (uint64_t)ret_var.inner;
27470                 if (ret_var.is_owned) {
27471                         ret_ref |= 1;
27472                 }
27473         }
27474         return ret_ref;
27475 }
27476
27477 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
27478         LDKCommitmentUpdate this_ptr_conv;
27479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27480         this_ptr_conv.is_owned = false;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27482         LDKUpdateFee val_conv;
27483         val_conv.inner = (void*)(val & (~1));
27484         val_conv.is_owned = (val & 1) || (val == 0);
27485         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27486         val_conv = UpdateFee_clone(&val_conv);
27487         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
27488 }
27489
27490 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
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         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
27496         uint64_t ret_ref = 0;
27497         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27498         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27500         ret_ref = (uint64_t)ret_var.inner;
27501         if (ret_var.is_owned) {
27502                 ret_ref |= 1;
27503         }
27504         return ret_ref;
27505 }
27506
27507 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
27508         LDKCommitmentUpdate this_ptr_conv;
27509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27510         this_ptr_conv.is_owned = false;
27511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27512         LDKCommitmentSigned val_conv;
27513         val_conv.inner = (void*)(val & (~1));
27514         val_conv.is_owned = (val & 1) || (val == 0);
27515         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27516         val_conv = CommitmentSigned_clone(&val_conv);
27517         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
27518 }
27519
27520 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) {
27521         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
27522         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
27523         if (update_add_htlcs_arg_constr.datalen > 0)
27524                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27525         else
27526                 update_add_htlcs_arg_constr.data = NULL;
27527         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
27528         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
27529                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
27530                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
27531                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
27532                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
27533                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
27534                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
27535                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
27536         }
27537         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
27538         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
27539         if (update_fulfill_htlcs_arg_constr.datalen > 0)
27540                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27541         else
27542                 update_fulfill_htlcs_arg_constr.data = NULL;
27543         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
27544         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
27545                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
27546                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
27547                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
27548                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
27549                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
27550                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
27551                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
27552         }
27553         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
27554         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
27555         if (update_fail_htlcs_arg_constr.datalen > 0)
27556                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27557         else
27558                 update_fail_htlcs_arg_constr.data = NULL;
27559         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
27560         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
27561                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
27562                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
27563                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
27564                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
27565                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
27566                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
27567                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
27568         }
27569         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
27570         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
27571         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
27572                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27573         else
27574                 update_fail_malformed_htlcs_arg_constr.data = NULL;
27575         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
27576         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
27577                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
27578                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
27579                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
27580                 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);
27581                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
27582                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
27583                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
27584         }
27585         LDKUpdateFee update_fee_arg_conv;
27586         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
27587         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
27588         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
27589         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
27590         LDKCommitmentSigned commitment_signed_arg_conv;
27591         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
27592         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
27593         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
27594         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
27595         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);
27596         uint64_t ret_ref = 0;
27597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27600         ret_ref = (uint64_t)ret_var.inner;
27601         if (ret_var.is_owned) {
27602                 ret_ref |= 1;
27603         }
27604         return ret_ref;
27605 }
27606
27607 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
27608         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
27609 uint64_t ret_ref = 0;
27610 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27611 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
27614 if (ret_var.is_owned) {
27615         ret_ref |= 1;
27616 }
27617         return ret_ref;
27618 }
27619 int64_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
27620         LDKCommitmentUpdate arg_conv;
27621         arg_conv.inner = (void*)(arg & (~1));
27622         arg_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27624         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
27625         return ret_val;
27626 }
27627
27628 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
27629         LDKCommitmentUpdate orig_conv;
27630         orig_conv.inner = (void*)(orig & (~1));
27631         orig_conv.is_owned = false;
27632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27633         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
27634         uint64_t ret_ref = 0;
27635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27638         ret_ref = (uint64_t)ret_var.inner;
27639         if (ret_var.is_owned) {
27640                 ret_ref |= 1;
27641         }
27642         return ret_ref;
27643 }
27644
27645 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
27646         if ((this_ptr & 1) != 0) return;
27647         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27648         CHECK_ACCESS(this_ptr_ptr);
27649         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
27650         FREE((void*)this_ptr);
27651         ChannelMessageHandler_free(this_ptr_conv);
27652 }
27653
27654 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
27655         if ((this_ptr & 1) != 0) return;
27656         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27657         CHECK_ACCESS(this_ptr_ptr);
27658         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
27659         FREE((void*)this_ptr);
27660         RoutingMessageHandler_free(this_ptr_conv);
27661 }
27662
27663 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
27664         LDKAcceptChannel obj_conv;
27665         obj_conv.inner = (void*)(obj & (~1));
27666         obj_conv.is_owned = false;
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27668         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
27669         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27670         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27671         CVec_u8Z_free(ret_var);
27672         return ret_arr;
27673 }
27674
27675 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
27676         LDKu8slice ser_ref;
27677         ser_ref.datalen = ser->arr_len;
27678         ser_ref.data = ser->elems;
27679         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
27680         *ret_conv = AcceptChannel_read(ser_ref);
27681         return (uint64_t)ret_conv;
27682 }
27683
27684 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
27685         LDKAnnouncementSignatures obj_conv;
27686         obj_conv.inner = (void*)(obj & (~1));
27687         obj_conv.is_owned = false;
27688         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27689         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
27690         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27691         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27692         CVec_u8Z_free(ret_var);
27693         return ret_arr;
27694 }
27695
27696 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
27697         LDKu8slice ser_ref;
27698         ser_ref.datalen = ser->arr_len;
27699         ser_ref.data = ser->elems;
27700         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
27701         *ret_conv = AnnouncementSignatures_read(ser_ref);
27702         return (uint64_t)ret_conv;
27703 }
27704
27705 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
27706         LDKChannelReestablish obj_conv;
27707         obj_conv.inner = (void*)(obj & (~1));
27708         obj_conv.is_owned = false;
27709         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27710         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
27711         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27712         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27713         CVec_u8Z_free(ret_var);
27714         return ret_arr;
27715 }
27716
27717 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
27718         LDKu8slice ser_ref;
27719         ser_ref.datalen = ser->arr_len;
27720         ser_ref.data = ser->elems;
27721         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
27722         *ret_conv = ChannelReestablish_read(ser_ref);
27723         return (uint64_t)ret_conv;
27724 }
27725
27726 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
27727         LDKClosingSigned obj_conv;
27728         obj_conv.inner = (void*)(obj & (~1));
27729         obj_conv.is_owned = false;
27730         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27731         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
27732         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27733         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27734         CVec_u8Z_free(ret_var);
27735         return ret_arr;
27736 }
27737
27738 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
27739         LDKu8slice ser_ref;
27740         ser_ref.datalen = ser->arr_len;
27741         ser_ref.data = ser->elems;
27742         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
27743         *ret_conv = ClosingSigned_read(ser_ref);
27744         return (uint64_t)ret_conv;
27745 }
27746
27747 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
27748         LDKClosingSignedFeeRange obj_conv;
27749         obj_conv.inner = (void*)(obj & (~1));
27750         obj_conv.is_owned = false;
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27752         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
27753         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27754         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27755         CVec_u8Z_free(ret_var);
27756         return ret_arr;
27757 }
27758
27759 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
27760         LDKu8slice ser_ref;
27761         ser_ref.datalen = ser->arr_len;
27762         ser_ref.data = ser->elems;
27763         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
27764         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
27765         return (uint64_t)ret_conv;
27766 }
27767
27768 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
27769         LDKCommitmentSigned obj_conv;
27770         obj_conv.inner = (void*)(obj & (~1));
27771         obj_conv.is_owned = false;
27772         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27773         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
27774         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27775         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27776         CVec_u8Z_free(ret_var);
27777         return ret_arr;
27778 }
27779
27780 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
27781         LDKu8slice ser_ref;
27782         ser_ref.datalen = ser->arr_len;
27783         ser_ref.data = ser->elems;
27784         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
27785         *ret_conv = CommitmentSigned_read(ser_ref);
27786         return (uint64_t)ret_conv;
27787 }
27788
27789 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
27790         LDKFundingCreated obj_conv;
27791         obj_conv.inner = (void*)(obj & (~1));
27792         obj_conv.is_owned = false;
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27794         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
27795         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27796         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27797         CVec_u8Z_free(ret_var);
27798         return ret_arr;
27799 }
27800
27801 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
27802         LDKu8slice ser_ref;
27803         ser_ref.datalen = ser->arr_len;
27804         ser_ref.data = ser->elems;
27805         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
27806         *ret_conv = FundingCreated_read(ser_ref);
27807         return (uint64_t)ret_conv;
27808 }
27809
27810 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
27811         LDKFundingSigned obj_conv;
27812         obj_conv.inner = (void*)(obj & (~1));
27813         obj_conv.is_owned = false;
27814         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27815         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
27816         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27817         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27818         CVec_u8Z_free(ret_var);
27819         return ret_arr;
27820 }
27821
27822 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
27823         LDKu8slice ser_ref;
27824         ser_ref.datalen = ser->arr_len;
27825         ser_ref.data = ser->elems;
27826         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
27827         *ret_conv = FundingSigned_read(ser_ref);
27828         return (uint64_t)ret_conv;
27829 }
27830
27831 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
27832         LDKFundingLocked obj_conv;
27833         obj_conv.inner = (void*)(obj & (~1));
27834         obj_conv.is_owned = false;
27835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27836         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
27837         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27838         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27839         CVec_u8Z_free(ret_var);
27840         return ret_arr;
27841 }
27842
27843 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
27844         LDKu8slice ser_ref;
27845         ser_ref.datalen = ser->arr_len;
27846         ser_ref.data = ser->elems;
27847         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
27848         *ret_conv = FundingLocked_read(ser_ref);
27849         return (uint64_t)ret_conv;
27850 }
27851
27852 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
27853         LDKInit obj_conv;
27854         obj_conv.inner = (void*)(obj & (~1));
27855         obj_conv.is_owned = false;
27856         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27857         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
27858         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27859         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27860         CVec_u8Z_free(ret_var);
27861         return ret_arr;
27862 }
27863
27864 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
27865         LDKu8slice ser_ref;
27866         ser_ref.datalen = ser->arr_len;
27867         ser_ref.data = ser->elems;
27868         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
27869         *ret_conv = Init_read(ser_ref);
27870         return (uint64_t)ret_conv;
27871 }
27872
27873 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
27874         LDKOpenChannel obj_conv;
27875         obj_conv.inner = (void*)(obj & (~1));
27876         obj_conv.is_owned = false;
27877         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27878         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
27879         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27880         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27881         CVec_u8Z_free(ret_var);
27882         return ret_arr;
27883 }
27884
27885 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
27886         LDKu8slice ser_ref;
27887         ser_ref.datalen = ser->arr_len;
27888         ser_ref.data = ser->elems;
27889         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
27890         *ret_conv = OpenChannel_read(ser_ref);
27891         return (uint64_t)ret_conv;
27892 }
27893
27894 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
27895         LDKRevokeAndACK obj_conv;
27896         obj_conv.inner = (void*)(obj & (~1));
27897         obj_conv.is_owned = false;
27898         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27899         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
27900         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27901         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27902         CVec_u8Z_free(ret_var);
27903         return ret_arr;
27904 }
27905
27906 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
27907         LDKu8slice ser_ref;
27908         ser_ref.datalen = ser->arr_len;
27909         ser_ref.data = ser->elems;
27910         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
27911         *ret_conv = RevokeAndACK_read(ser_ref);
27912         return (uint64_t)ret_conv;
27913 }
27914
27915 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
27916         LDKShutdown obj_conv;
27917         obj_conv.inner = (void*)(obj & (~1));
27918         obj_conv.is_owned = false;
27919         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27920         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
27921         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27922         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27923         CVec_u8Z_free(ret_var);
27924         return ret_arr;
27925 }
27926
27927 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
27928         LDKu8slice ser_ref;
27929         ser_ref.datalen = ser->arr_len;
27930         ser_ref.data = ser->elems;
27931         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
27932         *ret_conv = Shutdown_read(ser_ref);
27933         return (uint64_t)ret_conv;
27934 }
27935
27936 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
27937         LDKUpdateFailHTLC obj_conv;
27938         obj_conv.inner = (void*)(obj & (~1));
27939         obj_conv.is_owned = false;
27940         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27941         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
27942         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27943         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27944         CVec_u8Z_free(ret_var);
27945         return ret_arr;
27946 }
27947
27948 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
27949         LDKu8slice ser_ref;
27950         ser_ref.datalen = ser->arr_len;
27951         ser_ref.data = ser->elems;
27952         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
27953         *ret_conv = UpdateFailHTLC_read(ser_ref);
27954         return (uint64_t)ret_conv;
27955 }
27956
27957 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
27958         LDKUpdateFailMalformedHTLC obj_conv;
27959         obj_conv.inner = (void*)(obj & (~1));
27960         obj_conv.is_owned = false;
27961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27962         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
27963         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27964         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27965         CVec_u8Z_free(ret_var);
27966         return ret_arr;
27967 }
27968
27969 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
27970         LDKu8slice ser_ref;
27971         ser_ref.datalen = ser->arr_len;
27972         ser_ref.data = ser->elems;
27973         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
27974         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
27975         return (uint64_t)ret_conv;
27976 }
27977
27978 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
27979         LDKUpdateFee obj_conv;
27980         obj_conv.inner = (void*)(obj & (~1));
27981         obj_conv.is_owned = false;
27982         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27983         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
27984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
27985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27986         CVec_u8Z_free(ret_var);
27987         return ret_arr;
27988 }
27989
27990 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
27991         LDKu8slice ser_ref;
27992         ser_ref.datalen = ser->arr_len;
27993         ser_ref.data = ser->elems;
27994         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
27995         *ret_conv = UpdateFee_read(ser_ref);
27996         return (uint64_t)ret_conv;
27997 }
27998
27999 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
28000         LDKUpdateFulfillHTLC obj_conv;
28001         obj_conv.inner = (void*)(obj & (~1));
28002         obj_conv.is_owned = false;
28003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28004         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
28005         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28006         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28007         CVec_u8Z_free(ret_var);
28008         return ret_arr;
28009 }
28010
28011 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
28012         LDKu8slice ser_ref;
28013         ser_ref.datalen = ser->arr_len;
28014         ser_ref.data = ser->elems;
28015         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
28016         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
28017         return (uint64_t)ret_conv;
28018 }
28019
28020 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
28021         LDKUpdateAddHTLC obj_conv;
28022         obj_conv.inner = (void*)(obj & (~1));
28023         obj_conv.is_owned = false;
28024         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28025         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
28026         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28027         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28028         CVec_u8Z_free(ret_var);
28029         return ret_arr;
28030 }
28031
28032 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
28033         LDKu8slice ser_ref;
28034         ser_ref.datalen = ser->arr_len;
28035         ser_ref.data = ser->elems;
28036         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
28037         *ret_conv = UpdateAddHTLC_read(ser_ref);
28038         return (uint64_t)ret_conv;
28039 }
28040
28041 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
28042         LDKPing obj_conv;
28043         obj_conv.inner = (void*)(obj & (~1));
28044         obj_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28046         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
28047         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28048         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28049         CVec_u8Z_free(ret_var);
28050         return ret_arr;
28051 }
28052
28053 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
28054         LDKu8slice ser_ref;
28055         ser_ref.datalen = ser->arr_len;
28056         ser_ref.data = ser->elems;
28057         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
28058         *ret_conv = Ping_read(ser_ref);
28059         return (uint64_t)ret_conv;
28060 }
28061
28062 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
28063         LDKPong obj_conv;
28064         obj_conv.inner = (void*)(obj & (~1));
28065         obj_conv.is_owned = false;
28066         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28067         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
28068         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28069         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28070         CVec_u8Z_free(ret_var);
28071         return ret_arr;
28072 }
28073
28074 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
28075         LDKu8slice ser_ref;
28076         ser_ref.datalen = ser->arr_len;
28077         ser_ref.data = ser->elems;
28078         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
28079         *ret_conv = Pong_read(ser_ref);
28080         return (uint64_t)ret_conv;
28081 }
28082
28083 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
28084         LDKUnsignedChannelAnnouncement obj_conv;
28085         obj_conv.inner = (void*)(obj & (~1));
28086         obj_conv.is_owned = false;
28087         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28088         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
28089         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28090         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28091         CVec_u8Z_free(ret_var);
28092         return ret_arr;
28093 }
28094
28095 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
28096         LDKu8slice ser_ref;
28097         ser_ref.datalen = ser->arr_len;
28098         ser_ref.data = ser->elems;
28099         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
28100         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
28101         return (uint64_t)ret_conv;
28102 }
28103
28104 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
28105         LDKChannelAnnouncement obj_conv;
28106         obj_conv.inner = (void*)(obj & (~1));
28107         obj_conv.is_owned = false;
28108         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28109         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
28110         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28111         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28112         CVec_u8Z_free(ret_var);
28113         return ret_arr;
28114 }
28115
28116 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
28117         LDKu8slice ser_ref;
28118         ser_ref.datalen = ser->arr_len;
28119         ser_ref.data = ser->elems;
28120         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
28121         *ret_conv = ChannelAnnouncement_read(ser_ref);
28122         return (uint64_t)ret_conv;
28123 }
28124
28125 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
28126         LDKUnsignedChannelUpdate obj_conv;
28127         obj_conv.inner = (void*)(obj & (~1));
28128         obj_conv.is_owned = false;
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28130         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
28131         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28132         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28133         CVec_u8Z_free(ret_var);
28134         return ret_arr;
28135 }
28136
28137 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
28138         LDKu8slice ser_ref;
28139         ser_ref.datalen = ser->arr_len;
28140         ser_ref.data = ser->elems;
28141         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
28142         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
28143         return (uint64_t)ret_conv;
28144 }
28145
28146 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
28147         LDKChannelUpdate obj_conv;
28148         obj_conv.inner = (void*)(obj & (~1));
28149         obj_conv.is_owned = false;
28150         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28151         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
28152         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28153         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28154         CVec_u8Z_free(ret_var);
28155         return ret_arr;
28156 }
28157
28158 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
28159         LDKu8slice ser_ref;
28160         ser_ref.datalen = ser->arr_len;
28161         ser_ref.data = ser->elems;
28162         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
28163         *ret_conv = ChannelUpdate_read(ser_ref);
28164         return (uint64_t)ret_conv;
28165 }
28166
28167 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
28168         LDKErrorMessage obj_conv;
28169         obj_conv.inner = (void*)(obj & (~1));
28170         obj_conv.is_owned = false;
28171         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28172         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
28173         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28174         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28175         CVec_u8Z_free(ret_var);
28176         return ret_arr;
28177 }
28178
28179 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
28180         LDKu8slice ser_ref;
28181         ser_ref.datalen = ser->arr_len;
28182         ser_ref.data = ser->elems;
28183         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
28184         *ret_conv = ErrorMessage_read(ser_ref);
28185         return (uint64_t)ret_conv;
28186 }
28187
28188 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
28189         LDKUnsignedNodeAnnouncement obj_conv;
28190         obj_conv.inner = (void*)(obj & (~1));
28191         obj_conv.is_owned = false;
28192         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28193         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
28194         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28195         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28196         CVec_u8Z_free(ret_var);
28197         return ret_arr;
28198 }
28199
28200 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
28201         LDKu8slice ser_ref;
28202         ser_ref.datalen = ser->arr_len;
28203         ser_ref.data = ser->elems;
28204         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
28205         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
28206         return (uint64_t)ret_conv;
28207 }
28208
28209 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
28210         LDKNodeAnnouncement obj_conv;
28211         obj_conv.inner = (void*)(obj & (~1));
28212         obj_conv.is_owned = false;
28213         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28214         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
28215         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28216         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28217         CVec_u8Z_free(ret_var);
28218         return ret_arr;
28219 }
28220
28221 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
28222         LDKu8slice ser_ref;
28223         ser_ref.datalen = ser->arr_len;
28224         ser_ref.data = ser->elems;
28225         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
28226         *ret_conv = NodeAnnouncement_read(ser_ref);
28227         return (uint64_t)ret_conv;
28228 }
28229
28230 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
28231         LDKu8slice ser_ref;
28232         ser_ref.datalen = ser->arr_len;
28233         ser_ref.data = ser->elems;
28234         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
28235         *ret_conv = QueryShortChannelIds_read(ser_ref);
28236         return (uint64_t)ret_conv;
28237 }
28238
28239 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
28240         LDKQueryShortChannelIds obj_conv;
28241         obj_conv.inner = (void*)(obj & (~1));
28242         obj_conv.is_owned = false;
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28244         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
28245         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28246         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28247         CVec_u8Z_free(ret_var);
28248         return ret_arr;
28249 }
28250
28251 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
28252         LDKReplyShortChannelIdsEnd obj_conv;
28253         obj_conv.inner = (void*)(obj & (~1));
28254         obj_conv.is_owned = false;
28255         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28256         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
28257         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28258         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28259         CVec_u8Z_free(ret_var);
28260         return ret_arr;
28261 }
28262
28263 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
28264         LDKu8slice ser_ref;
28265         ser_ref.datalen = ser->arr_len;
28266         ser_ref.data = ser->elems;
28267         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
28268         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
28269         return (uint64_t)ret_conv;
28270 }
28271
28272 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
28273         LDKQueryChannelRange this_arg_conv;
28274         this_arg_conv.inner = (void*)(this_arg & (~1));
28275         this_arg_conv.is_owned = false;
28276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28277         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
28278         return ret_val;
28279 }
28280
28281 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
28282         LDKQueryChannelRange obj_conv;
28283         obj_conv.inner = (void*)(obj & (~1));
28284         obj_conv.is_owned = false;
28285         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28286         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
28287         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28288         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28289         CVec_u8Z_free(ret_var);
28290         return ret_arr;
28291 }
28292
28293 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
28294         LDKu8slice ser_ref;
28295         ser_ref.datalen = ser->arr_len;
28296         ser_ref.data = ser->elems;
28297         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
28298         *ret_conv = QueryChannelRange_read(ser_ref);
28299         return (uint64_t)ret_conv;
28300 }
28301
28302 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
28303         LDKu8slice ser_ref;
28304         ser_ref.datalen = ser->arr_len;
28305         ser_ref.data = ser->elems;
28306         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
28307         *ret_conv = ReplyChannelRange_read(ser_ref);
28308         return (uint64_t)ret_conv;
28309 }
28310
28311 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
28312         LDKReplyChannelRange obj_conv;
28313         obj_conv.inner = (void*)(obj & (~1));
28314         obj_conv.is_owned = false;
28315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28316         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
28317         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28318         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28319         CVec_u8Z_free(ret_var);
28320         return ret_arr;
28321 }
28322
28323 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
28324         LDKGossipTimestampFilter obj_conv;
28325         obj_conv.inner = (void*)(obj & (~1));
28326         obj_conv.is_owned = false;
28327         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28328         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
28329         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28330         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28331         CVec_u8Z_free(ret_var);
28332         return ret_arr;
28333 }
28334
28335 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
28336         LDKu8slice ser_ref;
28337         ser_ref.datalen = ser->arr_len;
28338         ser_ref.data = ser->elems;
28339         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
28340         *ret_conv = GossipTimestampFilter_read(ser_ref);
28341         return (uint64_t)ret_conv;
28342 }
28343
28344 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
28345         if ((this_ptr & 1) != 0) return;
28346         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28347         CHECK_ACCESS(this_ptr_ptr);
28348         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
28349         FREE((void*)this_ptr);
28350         CustomMessageHandler_free(this_ptr_conv);
28351 }
28352
28353 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
28354         LDKIgnoringMessageHandler this_obj_conv;
28355         this_obj_conv.inner = (void*)(this_obj & (~1));
28356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28358         IgnoringMessageHandler_free(this_obj_conv);
28359 }
28360
28361 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
28362         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
28363         uint64_t ret_ref = 0;
28364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28367         ret_ref = (uint64_t)ret_var.inner;
28368         if (ret_var.is_owned) {
28369                 ret_ref |= 1;
28370         }
28371         return ret_ref;
28372 }
28373
28374 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28375         LDKIgnoringMessageHandler this_arg_conv;
28376         this_arg_conv.inner = (void*)(this_arg & (~1));
28377         this_arg_conv.is_owned = false;
28378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28379         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28380         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28381         return (uint64_t)ret_ret;
28382 }
28383
28384 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
28385         LDKIgnoringMessageHandler this_arg_conv;
28386         this_arg_conv.inner = (void*)(this_arg & (~1));
28387         this_arg_conv.is_owned = false;
28388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28389         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
28390         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
28391         return (uint64_t)ret_ret;
28392 }
28393
28394 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
28395         LDKIgnoringMessageHandler this_arg_conv;
28396         this_arg_conv.inner = (void*)(this_arg & (~1));
28397         this_arg_conv.is_owned = false;
28398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28399         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
28400         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
28401         return (uint64_t)ret_ret;
28402 }
28403
28404 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
28405         LDKIgnoringMessageHandler this_arg_conv;
28406         this_arg_conv.inner = (void*)(this_arg & (~1));
28407         this_arg_conv.is_owned = false;
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28409         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
28410         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
28411         return (uint64_t)ret_ret;
28412 }
28413
28414 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
28415         LDKErroringMessageHandler this_obj_conv;
28416         this_obj_conv.inner = (void*)(this_obj & (~1));
28417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28419         ErroringMessageHandler_free(this_obj_conv);
28420 }
28421
28422 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
28423         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
28424         uint64_t ret_ref = 0;
28425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28428         ret_ref = (uint64_t)ret_var.inner;
28429         if (ret_var.is_owned) {
28430                 ret_ref |= 1;
28431         }
28432         return ret_ref;
28433 }
28434
28435 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28436         LDKErroringMessageHandler this_arg_conv;
28437         this_arg_conv.inner = (void*)(this_arg & (~1));
28438         this_arg_conv.is_owned = false;
28439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28440         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28441         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28442         return (uint64_t)ret_ret;
28443 }
28444
28445 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
28446         LDKErroringMessageHandler this_arg_conv;
28447         this_arg_conv.inner = (void*)(this_arg & (~1));
28448         this_arg_conv.is_owned = false;
28449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28450         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
28451         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
28452         return (uint64_t)ret_ret;
28453 }
28454
28455 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
28456         LDKMessageHandler this_obj_conv;
28457         this_obj_conv.inner = (void*)(this_obj & (~1));
28458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28460         MessageHandler_free(this_obj_conv);
28461 }
28462
28463 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
28464         LDKMessageHandler this_ptr_conv;
28465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28466         this_ptr_conv.is_owned = false;
28467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28468         // WARNING: This object doesn't live past this scope, needs clone!
28469         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
28470         return ret_ret;
28471 }
28472
28473 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
28474         LDKMessageHandler this_ptr_conv;
28475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28476         this_ptr_conv.is_owned = false;
28477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28478         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28479         CHECK_ACCESS(val_ptr);
28480         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
28481         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
28482 }
28483
28484 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
28485         LDKMessageHandler this_ptr_conv;
28486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28487         this_ptr_conv.is_owned = false;
28488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28489         // WARNING: This object doesn't live past this scope, needs clone!
28490         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
28491         return ret_ret;
28492 }
28493
28494 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
28495         LDKMessageHandler this_ptr_conv;
28496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28497         this_ptr_conv.is_owned = false;
28498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28499         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28500         CHECK_ACCESS(val_ptr);
28501         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
28502         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
28503 }
28504
28505 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
28506         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
28507         CHECK_ACCESS(chan_handler_arg_ptr);
28508         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
28509         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
28510         CHECK_ACCESS(route_handler_arg_ptr);
28511         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
28512         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
28513         uint64_t ret_ref = 0;
28514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28517         ret_ref = (uint64_t)ret_var.inner;
28518         if (ret_var.is_owned) {
28519                 ret_ref |= 1;
28520         }
28521         return ret_ref;
28522 }
28523
28524 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
28525         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28526         *ret_ret = SocketDescriptor_clone(arg);
28527         return (uint64_t)ret_ret;
28528 }
28529 int64_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
28530         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
28531         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28532         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
28533         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
28534         return ret_val;
28535 }
28536
28537 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
28538         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
28539         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28540         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
28541         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28542         *ret_ret = SocketDescriptor_clone(orig_conv);
28543         return (uint64_t)ret_ret;
28544 }
28545
28546 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
28547         if ((this_ptr & 1) != 0) return;
28548         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28549         CHECK_ACCESS(this_ptr_ptr);
28550         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
28551         FREE((void*)this_ptr);
28552         SocketDescriptor_free(this_ptr_conv);
28553 }
28554
28555 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
28556         LDKPeerHandleError this_obj_conv;
28557         this_obj_conv.inner = (void*)(this_obj & (~1));
28558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28560         PeerHandleError_free(this_obj_conv);
28561 }
28562
28563 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
28564         LDKPeerHandleError this_ptr_conv;
28565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28566         this_ptr_conv.is_owned = false;
28567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28568         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
28569         return ret_val;
28570 }
28571
28572 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
28573         LDKPeerHandleError this_ptr_conv;
28574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28575         this_ptr_conv.is_owned = false;
28576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28577         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
28578 }
28579
28580 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
28581         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
28582         uint64_t ret_ref = 0;
28583         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28584         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28586         ret_ref = (uint64_t)ret_var.inner;
28587         if (ret_var.is_owned) {
28588                 ret_ref |= 1;
28589         }
28590         return ret_ref;
28591 }
28592
28593 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
28594         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
28595 uint64_t ret_ref = 0;
28596 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28597 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
28600 if (ret_var.is_owned) {
28601         ret_ref |= 1;
28602 }
28603         return ret_ref;
28604 }
28605 int64_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
28606         LDKPeerHandleError arg_conv;
28607         arg_conv.inner = (void*)(arg & (~1));
28608         arg_conv.is_owned = false;
28609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28610         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
28611         return ret_val;
28612 }
28613
28614 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
28615         LDKPeerHandleError orig_conv;
28616         orig_conv.inner = (void*)(orig & (~1));
28617         orig_conv.is_owned = false;
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28619         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
28620         uint64_t ret_ref = 0;
28621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28624         ret_ref = (uint64_t)ret_var.inner;
28625         if (ret_var.is_owned) {
28626                 ret_ref |= 1;
28627         }
28628         return ret_ref;
28629 }
28630
28631 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
28632         LDKPeerManager this_obj_conv;
28633         this_obj_conv.inner = (void*)(this_obj & (~1));
28634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28636         PeerManager_free(this_obj_conv);
28637 }
28638
28639 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) {
28640         LDKMessageHandler message_handler_conv;
28641         message_handler_conv.inner = (void*)(message_handler & (~1));
28642         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
28644         // Warning: we need a move here but no clone is available for LDKMessageHandler
28645         LDKSecretKey our_node_secret_ref;
28646         CHECK(our_node_secret->arr_len == 32);
28647         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32);
28648         unsigned char ephemeral_random_data_arr[32];
28649         CHECK(ephemeral_random_data->arr_len == 32);
28650         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32);
28651         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
28652         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28653         CHECK_ACCESS(logger_ptr);
28654         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28655         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
28656         CHECK_ACCESS(custom_message_handler_ptr);
28657         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
28658         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
28659         uint64_t ret_ref = 0;
28660         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28661         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28663         ret_ref = (uint64_t)ret_var.inner;
28664         if (ret_var.is_owned) {
28665                 ret_ref |= 1;
28666         }
28667         return ret_ref;
28668 }
28669
28670 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
28671         LDKPeerManager this_arg_conv;
28672         this_arg_conv.inner = (void*)(this_arg & (~1));
28673         this_arg_conv.is_owned = false;
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28675         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
28676         ptrArray ret_arr = NULL;
28677         ret_arr = init_ptrArray(ret_var.datalen);
28678         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
28679         for (size_t m = 0; m < ret_var.datalen; m++) {
28680                 int8_tArray ret_conv_12_arr = init_int8_tArray(33);
28681                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
28682                 ret_arr_ptr[m] = ret_conv_12_arr;
28683         }
28684         
28685         FREE(ret_var.data);
28686         return ret_arr;
28687 }
28688
28689 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) {
28690         LDKPeerManager this_arg_conv;
28691         this_arg_conv.inner = (void*)(this_arg & (~1));
28692         this_arg_conv.is_owned = false;
28693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28694         LDKPublicKey their_node_id_ref;
28695         CHECK(their_node_id->arr_len == 33);
28696         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33);
28697         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28698         CHECK_ACCESS(descriptor_ptr);
28699         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28700         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
28701         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
28702         return (uint64_t)ret_conv;
28703 }
28704
28705 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
28706         LDKPeerManager this_arg_conv;
28707         this_arg_conv.inner = (void*)(this_arg & (~1));
28708         this_arg_conv.is_owned = false;
28709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28710         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28711         CHECK_ACCESS(descriptor_ptr);
28712         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28713         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28714         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
28715         return (uint64_t)ret_conv;
28716 }
28717
28718 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(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*)(((uint64_t)descriptor) & ~1);
28724         if (!(descriptor & 1)) { 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_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
28728         return (uint64_t)ret_conv;
28729 }
28730
28731 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
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* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
28737         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
28738         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
28739         LDKu8slice data_ref;
28740         data_ref.datalen = data->arr_len;
28741         data_ref.data = data->elems;
28742         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
28743         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
28744         return (uint64_t)ret_conv;
28745 }
28746
28747 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
28748         LDKPeerManager this_arg_conv;
28749         this_arg_conv.inner = (void*)(this_arg & (~1));
28750         this_arg_conv.is_owned = false;
28751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28752         PeerManager_process_events(&this_arg_conv);
28753 }
28754
28755 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
28756         LDKPeerManager this_arg_conv;
28757         this_arg_conv.inner = (void*)(this_arg & (~1));
28758         this_arg_conv.is_owned = false;
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28760         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28761         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28762         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28763         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
28764 }
28765
28766 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) {
28767         LDKPeerManager this_arg_conv;
28768         this_arg_conv.inner = (void*)(this_arg & (~1));
28769         this_arg_conv.is_owned = false;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28771         LDKPublicKey node_id_ref;
28772         CHECK(node_id->arr_len == 33);
28773         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
28774         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
28775 }
28776
28777 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
28778         LDKPeerManager this_arg_conv;
28779         this_arg_conv.inner = (void*)(this_arg & (~1));
28780         this_arg_conv.is_owned = false;
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28782         PeerManager_disconnect_all_peers(&this_arg_conv);
28783 }
28784
28785 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
28786         LDKPeerManager this_arg_conv;
28787         this_arg_conv.inner = (void*)(this_arg & (~1));
28788         this_arg_conv.is_owned = false;
28789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28790         PeerManager_timer_tick_occurred(&this_arg_conv);
28791 }
28792
28793 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
28794         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
28795         return ret_val;
28796 }
28797
28798 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
28799         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
28800         return ret_val;
28801 }
28802
28803 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
28804         unsigned char commitment_seed_arr[32];
28805         CHECK(commitment_seed->arr_len == 32);
28806         memcpy(commitment_seed_arr, commitment_seed->elems, 32);
28807         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
28808         int8_tArray ret_arr = init_int8_tArray(32);
28809         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
28810         return ret_arr;
28811 }
28812
28813 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) {
28814         LDKCVec_u8Z to_holder_script_ref;
28815         to_holder_script_ref.datalen = to_holder_script->arr_len;
28816         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28817         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen);
28818         LDKCVec_u8Z to_counterparty_script_ref;
28819         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
28820         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28821         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen);
28822         LDKOutPoint funding_outpoint_conv;
28823         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28824         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28825         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
28826         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28827         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);
28828         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
28829         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28830         Transaction_free(ret_var);
28831         return ret_arr;
28832 }
28833
28834 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
28835         LDKPublicKey per_commitment_point_ref;
28836         CHECK(per_commitment_point->arr_len == 33);
28837         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
28838         unsigned char base_secret_arr[32];
28839         CHECK(base_secret->arr_len == 32);
28840         memcpy(base_secret_arr, base_secret->elems, 32);
28841         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
28842         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28843         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
28844         return (uint64_t)ret_conv;
28845 }
28846
28847 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
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);
28851         LDKPublicKey base_point_ref;
28852         CHECK(base_point->arr_len == 33);
28853         memcpy(base_point_ref.compressed_form, base_point->elems, 33);
28854         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28855         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
28856         return (uint64_t)ret_conv;
28857 }
28858
28859 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) {
28860         unsigned char per_commitment_secret_arr[32];
28861         CHECK(per_commitment_secret->arr_len == 32);
28862         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32);
28863         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
28864         unsigned char countersignatory_revocation_base_secret_arr[32];
28865         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
28866         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32);
28867         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
28868         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28869         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
28870         return (uint64_t)ret_conv;
28871 }
28872
28873 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) {
28874         LDKPublicKey per_commitment_point_ref;
28875         CHECK(per_commitment_point->arr_len == 33);
28876         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
28877         LDKPublicKey countersignatory_revocation_base_point_ref;
28878         CHECK(countersignatory_revocation_base_point->arr_len == 33);
28879         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33);
28880         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28881         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
28882         return (uint64_t)ret_conv;
28883 }
28884
28885 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
28886         LDKTxCreationKeys this_obj_conv;
28887         this_obj_conv.inner = (void*)(this_obj & (~1));
28888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28890         TxCreationKeys_free(this_obj_conv);
28891 }
28892
28893 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
28894         LDKTxCreationKeys this_ptr_conv;
28895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28896         this_ptr_conv.is_owned = false;
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28898         int8_tArray ret_arr = init_int8_tArray(33);
28899         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28900         return ret_arr;
28901 }
28902
28903 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
28904         LDKTxCreationKeys this_ptr_conv;
28905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28906         this_ptr_conv.is_owned = false;
28907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28908         LDKPublicKey val_ref;
28909         CHECK(val->arr_len == 33);
28910         memcpy(val_ref.compressed_form, val->elems, 33);
28911         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
28912 }
28913
28914 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
28915         LDKTxCreationKeys this_ptr_conv;
28916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28917         this_ptr_conv.is_owned = false;
28918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28919         int8_tArray ret_arr = init_int8_tArray(33);
28920         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
28921         return ret_arr;
28922 }
28923
28924 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
28925         LDKTxCreationKeys this_ptr_conv;
28926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28927         this_ptr_conv.is_owned = false;
28928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28929         LDKPublicKey val_ref;
28930         CHECK(val->arr_len == 33);
28931         memcpy(val_ref.compressed_form, val->elems, 33);
28932         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
28933 }
28934
28935 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
28936         LDKTxCreationKeys this_ptr_conv;
28937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28938         this_ptr_conv.is_owned = false;
28939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28940         int8_tArray ret_arr = init_int8_tArray(33);
28941         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
28942         return ret_arr;
28943 }
28944
28945 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
28946         LDKTxCreationKeys this_ptr_conv;
28947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28948         this_ptr_conv.is_owned = false;
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28950         LDKPublicKey val_ref;
28951         CHECK(val->arr_len == 33);
28952         memcpy(val_ref.compressed_form, val->elems, 33);
28953         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
28954 }
28955
28956 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
28957         LDKTxCreationKeys this_ptr_conv;
28958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28959         this_ptr_conv.is_owned = false;
28960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28961         int8_tArray ret_arr = init_int8_tArray(33);
28962         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
28963         return ret_arr;
28964 }
28965
28966 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
28967         LDKTxCreationKeys this_ptr_conv;
28968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28969         this_ptr_conv.is_owned = false;
28970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28971         LDKPublicKey val_ref;
28972         CHECK(val->arr_len == 33);
28973         memcpy(val_ref.compressed_form, val->elems, 33);
28974         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
28975 }
28976
28977 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
28978         LDKTxCreationKeys this_ptr_conv;
28979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28980         this_ptr_conv.is_owned = false;
28981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28982         int8_tArray ret_arr = init_int8_tArray(33);
28983         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
28984         return ret_arr;
28985 }
28986
28987 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) {
28988         LDKTxCreationKeys this_ptr_conv;
28989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28990         this_ptr_conv.is_owned = false;
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28992         LDKPublicKey val_ref;
28993         CHECK(val->arr_len == 33);
28994         memcpy(val_ref.compressed_form, val->elems, 33);
28995         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
28996 }
28997
28998 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) {
28999         LDKPublicKey per_commitment_point_arg_ref;
29000         CHECK(per_commitment_point_arg->arr_len == 33);
29001         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33);
29002         LDKPublicKey revocation_key_arg_ref;
29003         CHECK(revocation_key_arg->arr_len == 33);
29004         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33);
29005         LDKPublicKey broadcaster_htlc_key_arg_ref;
29006         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
29007         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33);
29008         LDKPublicKey countersignatory_htlc_key_arg_ref;
29009         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
29010         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33);
29011         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
29012         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
29013         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33);
29014         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);
29015         uint64_t ret_ref = 0;
29016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29019         ret_ref = (uint64_t)ret_var.inner;
29020         if (ret_var.is_owned) {
29021                 ret_ref |= 1;
29022         }
29023         return ret_ref;
29024 }
29025
29026 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
29027         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
29028 uint64_t ret_ref = 0;
29029 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29030 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29033 if (ret_var.is_owned) {
29034         ret_ref |= 1;
29035 }
29036         return ret_ref;
29037 }
29038 int64_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
29039         LDKTxCreationKeys arg_conv;
29040         arg_conv.inner = (void*)(arg & (~1));
29041         arg_conv.is_owned = false;
29042         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29043         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
29044         return ret_val;
29045 }
29046
29047 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
29048         LDKTxCreationKeys orig_conv;
29049         orig_conv.inner = (void*)(orig & (~1));
29050         orig_conv.is_owned = false;
29051         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29052         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
29053         uint64_t ret_ref = 0;
29054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29057         ret_ref = (uint64_t)ret_var.inner;
29058         if (ret_var.is_owned) {
29059                 ret_ref |= 1;
29060         }
29061         return ret_ref;
29062 }
29063
29064 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
29065         LDKTxCreationKeys obj_conv;
29066         obj_conv.inner = (void*)(obj & (~1));
29067         obj_conv.is_owned = false;
29068         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29069         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
29070         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29071         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29072         CVec_u8Z_free(ret_var);
29073         return ret_arr;
29074 }
29075
29076 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
29077         LDKu8slice ser_ref;
29078         ser_ref.datalen = ser->arr_len;
29079         ser_ref.data = ser->elems;
29080         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
29081         *ret_conv = TxCreationKeys_read(ser_ref);
29082         return (uint64_t)ret_conv;
29083 }
29084
29085 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
29086         LDKChannelPublicKeys this_obj_conv;
29087         this_obj_conv.inner = (void*)(this_obj & (~1));
29088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29090         ChannelPublicKeys_free(this_obj_conv);
29091 }
29092
29093 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
29094         LDKChannelPublicKeys this_ptr_conv;
29095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29096         this_ptr_conv.is_owned = false;
29097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29098         int8_tArray ret_arr = init_int8_tArray(33);
29099         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29100         return ret_arr;
29101 }
29102
29103 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29104         LDKChannelPublicKeys this_ptr_conv;
29105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29106         this_ptr_conv.is_owned = false;
29107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29108         LDKPublicKey val_ref;
29109         CHECK(val->arr_len == 33);
29110         memcpy(val_ref.compressed_form, val->elems, 33);
29111         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
29112 }
29113
29114 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
29115         LDKChannelPublicKeys this_ptr_conv;
29116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29117         this_ptr_conv.is_owned = false;
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29119         int8_tArray ret_arr = init_int8_tArray(33);
29120         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29121         return ret_arr;
29122 }
29123
29124 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29125         LDKChannelPublicKeys this_ptr_conv;
29126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29127         this_ptr_conv.is_owned = false;
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29129         LDKPublicKey val_ref;
29130         CHECK(val->arr_len == 33);
29131         memcpy(val_ref.compressed_form, val->elems, 33);
29132         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
29133 }
29134
29135 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
29136         LDKChannelPublicKeys this_ptr_conv;
29137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29138         this_ptr_conv.is_owned = false;
29139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29140         int8_tArray ret_arr = init_int8_tArray(33);
29141         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
29142         return ret_arr;
29143 }
29144
29145 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29146         LDKChannelPublicKeys this_ptr_conv;
29147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29148         this_ptr_conv.is_owned = false;
29149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29150         LDKPublicKey val_ref;
29151         CHECK(val->arr_len == 33);
29152         memcpy(val_ref.compressed_form, val->elems, 33);
29153         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
29154 }
29155
29156 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
29157         LDKChannelPublicKeys this_ptr_conv;
29158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29159         this_ptr_conv.is_owned = false;
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29161         int8_tArray ret_arr = init_int8_tArray(33);
29162         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29163         return ret_arr;
29164 }
29165
29166 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29167         LDKChannelPublicKeys this_ptr_conv;
29168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29169         this_ptr_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29171         LDKPublicKey val_ref;
29172         CHECK(val->arr_len == 33);
29173         memcpy(val_ref.compressed_form, val->elems, 33);
29174         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29175 }
29176
29177 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
29178         LDKChannelPublicKeys this_ptr_conv;
29179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29180         this_ptr_conv.is_owned = false;
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29182         int8_tArray ret_arr = init_int8_tArray(33);
29183         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29184         return ret_arr;
29185 }
29186
29187 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29188         LDKChannelPublicKeys this_ptr_conv;
29189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29190         this_ptr_conv.is_owned = false;
29191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29192         LDKPublicKey val_ref;
29193         CHECK(val->arr_len == 33);
29194         memcpy(val_ref.compressed_form, val->elems, 33);
29195         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
29196 }
29197
29198 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) {
29199         LDKPublicKey funding_pubkey_arg_ref;
29200         CHECK(funding_pubkey_arg->arr_len == 33);
29201         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33);
29202         LDKPublicKey revocation_basepoint_arg_ref;
29203         CHECK(revocation_basepoint_arg->arr_len == 33);
29204         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33);
29205         LDKPublicKey payment_point_arg_ref;
29206         CHECK(payment_point_arg->arr_len == 33);
29207         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33);
29208         LDKPublicKey delayed_payment_basepoint_arg_ref;
29209         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
29210         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33);
29211         LDKPublicKey htlc_basepoint_arg_ref;
29212         CHECK(htlc_basepoint_arg->arr_len == 33);
29213         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33);
29214         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);
29215         uint64_t ret_ref = 0;
29216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29219         ret_ref = (uint64_t)ret_var.inner;
29220         if (ret_var.is_owned) {
29221                 ret_ref |= 1;
29222         }
29223         return ret_ref;
29224 }
29225
29226 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
29227         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
29228 uint64_t ret_ref = 0;
29229 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29230 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29233 if (ret_var.is_owned) {
29234         ret_ref |= 1;
29235 }
29236         return ret_ref;
29237 }
29238 int64_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
29239         LDKChannelPublicKeys arg_conv;
29240         arg_conv.inner = (void*)(arg & (~1));
29241         arg_conv.is_owned = false;
29242         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29243         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
29244         return ret_val;
29245 }
29246
29247 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
29248         LDKChannelPublicKeys orig_conv;
29249         orig_conv.inner = (void*)(orig & (~1));
29250         orig_conv.is_owned = false;
29251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29252         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
29253         uint64_t ret_ref = 0;
29254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29257         ret_ref = (uint64_t)ret_var.inner;
29258         if (ret_var.is_owned) {
29259                 ret_ref |= 1;
29260         }
29261         return ret_ref;
29262 }
29263
29264 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
29265         LDKChannelPublicKeys obj_conv;
29266         obj_conv.inner = (void*)(obj & (~1));
29267         obj_conv.is_owned = false;
29268         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29269         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
29270         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29271         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29272         CVec_u8Z_free(ret_var);
29273         return ret_arr;
29274 }
29275
29276 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
29277         LDKu8slice ser_ref;
29278         ser_ref.datalen = ser->arr_len;
29279         ser_ref.data = ser->elems;
29280         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
29281         *ret_conv = ChannelPublicKeys_read(ser_ref);
29282         return (uint64_t)ret_conv;
29283 }
29284
29285 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) {
29286         LDKPublicKey per_commitment_point_ref;
29287         CHECK(per_commitment_point->arr_len == 33);
29288         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
29289         LDKPublicKey broadcaster_delayed_payment_base_ref;
29290         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
29291         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33);
29292         LDKPublicKey broadcaster_htlc_base_ref;
29293         CHECK(broadcaster_htlc_base->arr_len == 33);
29294         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33);
29295         LDKPublicKey countersignatory_revocation_base_ref;
29296         CHECK(countersignatory_revocation_base->arr_len == 33);
29297         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33);
29298         LDKPublicKey countersignatory_htlc_base_ref;
29299         CHECK(countersignatory_htlc_base->arr_len == 33);
29300         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33);
29301         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29302         *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);
29303         return (uint64_t)ret_conv;
29304 }
29305
29306 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) {
29307         LDKPublicKey per_commitment_point_ref;
29308         CHECK(per_commitment_point->arr_len == 33);
29309         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33);
29310         LDKChannelPublicKeys broadcaster_keys_conv;
29311         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
29312         broadcaster_keys_conv.is_owned = false;
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
29314         LDKChannelPublicKeys countersignatory_keys_conv;
29315         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
29316         countersignatory_keys_conv.is_owned = false;
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
29318         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29319         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
29320         return (uint64_t)ret_conv;
29321 }
29322
29323 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) {
29324         LDKPublicKey revocation_key_ref;
29325         CHECK(revocation_key->arr_len == 33);
29326         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33);
29327         LDKPublicKey broadcaster_delayed_payment_key_ref;
29328         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29329         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33);
29330         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
29331         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29332         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29333         CVec_u8Z_free(ret_var);
29334         return ret_arr;
29335 }
29336
29337 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
29338         LDKHTLCOutputInCommitment this_obj_conv;
29339         this_obj_conv.inner = (void*)(this_obj & (~1));
29340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29342         HTLCOutputInCommitment_free(this_obj_conv);
29343 }
29344
29345 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
29346         LDKHTLCOutputInCommitment this_ptr_conv;
29347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29348         this_ptr_conv.is_owned = false;
29349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29350         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
29351         return ret_val;
29352 }
29353
29354 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
29355         LDKHTLCOutputInCommitment this_ptr_conv;
29356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29357         this_ptr_conv.is_owned = false;
29358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29359         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
29360 }
29361
29362 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
29363         LDKHTLCOutputInCommitment this_ptr_conv;
29364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29365         this_ptr_conv.is_owned = false;
29366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29367         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
29368         return ret_val;
29369 }
29370
29371 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
29372         LDKHTLCOutputInCommitment this_ptr_conv;
29373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29374         this_ptr_conv.is_owned = false;
29375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29376         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
29377 }
29378
29379 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
29380         LDKHTLCOutputInCommitment this_ptr_conv;
29381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29382         this_ptr_conv.is_owned = false;
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29384         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
29385         return ret_val;
29386 }
29387
29388 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29389         LDKHTLCOutputInCommitment this_ptr_conv;
29390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29391         this_ptr_conv.is_owned = false;
29392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29393         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
29394 }
29395
29396 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
29397         LDKHTLCOutputInCommitment this_ptr_conv;
29398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29399         this_ptr_conv.is_owned = false;
29400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29401         int8_tArray ret_arr = init_int8_tArray(32);
29402         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
29403         return ret_arr;
29404 }
29405
29406 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29407         LDKHTLCOutputInCommitment this_ptr_conv;
29408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29409         this_ptr_conv.is_owned = false;
29410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29411         LDKThirtyTwoBytes val_ref;
29412         CHECK(val->arr_len == 32);
29413         memcpy(val_ref.data, val->elems, 32);
29414         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
29415 }
29416
29417 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
29418         LDKHTLCOutputInCommitment this_ptr_conv;
29419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29420         this_ptr_conv.is_owned = false;
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29422         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29423         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
29424         uint64_t ret_ref = (uint64_t)ret_copy;
29425         return ret_ref;
29426 }
29427
29428 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
29429         LDKHTLCOutputInCommitment this_ptr_conv;
29430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29431         this_ptr_conv.is_owned = false;
29432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29433         void* val_ptr = (void*)(((uint64_t)val) & ~1);
29434         CHECK_ACCESS(val_ptr);
29435         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29436         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
29437         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
29438 }
29439
29440 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) {
29441         LDKThirtyTwoBytes payment_hash_arg_ref;
29442         CHECK(payment_hash_arg->arr_len == 32);
29443         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32);
29444         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
29445         CHECK_ACCESS(transaction_output_index_arg_ptr);
29446         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
29447         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
29448         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
29449         uint64_t ret_ref = 0;
29450         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29451         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29453         ret_ref = (uint64_t)ret_var.inner;
29454         if (ret_var.is_owned) {
29455                 ret_ref |= 1;
29456         }
29457         return ret_ref;
29458 }
29459
29460 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
29461         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
29462 uint64_t ret_ref = 0;
29463 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29464 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29467 if (ret_var.is_owned) {
29468         ret_ref |= 1;
29469 }
29470         return ret_ref;
29471 }
29472 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
29473         LDKHTLCOutputInCommitment arg_conv;
29474         arg_conv.inner = (void*)(arg & (~1));
29475         arg_conv.is_owned = false;
29476         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29477         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
29478         return ret_val;
29479 }
29480
29481 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
29482         LDKHTLCOutputInCommitment orig_conv;
29483         orig_conv.inner = (void*)(orig & (~1));
29484         orig_conv.is_owned = false;
29485         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29486         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
29487         uint64_t ret_ref = 0;
29488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29491         ret_ref = (uint64_t)ret_var.inner;
29492         if (ret_var.is_owned) {
29493                 ret_ref |= 1;
29494         }
29495         return ret_ref;
29496 }
29497
29498 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
29499         LDKHTLCOutputInCommitment obj_conv;
29500         obj_conv.inner = (void*)(obj & (~1));
29501         obj_conv.is_owned = false;
29502         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29503         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
29504         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29505         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29506         CVec_u8Z_free(ret_var);
29507         return ret_arr;
29508 }
29509
29510 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
29511         LDKu8slice ser_ref;
29512         ser_ref.datalen = ser->arr_len;
29513         ser_ref.data = ser->elems;
29514         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
29515         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
29516         return (uint64_t)ret_conv;
29517 }
29518
29519 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
29520         LDKHTLCOutputInCommitment htlc_conv;
29521         htlc_conv.inner = (void*)(htlc & (~1));
29522         htlc_conv.is_owned = false;
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29524         LDKTxCreationKeys keys_conv;
29525         keys_conv.inner = (void*)(keys & (~1));
29526         keys_conv.is_owned = false;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
29528         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
29529         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29530         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29531         CVec_u8Z_free(ret_var);
29532         return ret_arr;
29533 }
29534
29535 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
29536         LDKPublicKey broadcaster_ref;
29537         CHECK(broadcaster->arr_len == 33);
29538         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33);
29539         LDKPublicKey countersignatory_ref;
29540         CHECK(countersignatory->arr_len == 33);
29541         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33);
29542         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
29543         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29544         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29545         CVec_u8Z_free(ret_var);
29546         return ret_arr;
29547 }
29548
29549 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) {
29550         unsigned char commitment_txid_arr[32];
29551         CHECK(commitment_txid->arr_len == 32);
29552         memcpy(commitment_txid_arr, commitment_txid->elems, 32);
29553         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
29554         LDKHTLCOutputInCommitment htlc_conv;
29555         htlc_conv.inner = (void*)(htlc & (~1));
29556         htlc_conv.is_owned = false;
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29558         LDKPublicKey broadcaster_delayed_payment_key_ref;
29559         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29560         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33);
29561         LDKPublicKey revocation_key_ref;
29562         CHECK(revocation_key->arr_len == 33);
29563         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33);
29564         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);
29565         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29566         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29567         Transaction_free(ret_var);
29568         return ret_arr;
29569 }
29570
29571 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
29572         LDKPublicKey funding_pubkey_ref;
29573         CHECK(funding_pubkey->arr_len == 33);
29574         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33);
29575         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
29576         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29577         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29578         CVec_u8Z_free(ret_var);
29579         return ret_arr;
29580 }
29581
29582 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
29583         LDKChannelTransactionParameters this_obj_conv;
29584         this_obj_conv.inner = (void*)(this_obj & (~1));
29585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29587         ChannelTransactionParameters_free(this_obj_conv);
29588 }
29589
29590 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
29591         LDKChannelTransactionParameters this_ptr_conv;
29592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29593         this_ptr_conv.is_owned = false;
29594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29595         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
29596         uint64_t ret_ref = 0;
29597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29600         ret_ref = (uint64_t)ret_var.inner;
29601         if (ret_var.is_owned) {
29602                 ret_ref |= 1;
29603         }
29604         return ret_ref;
29605 }
29606
29607 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
29608         LDKChannelTransactionParameters this_ptr_conv;
29609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29610         this_ptr_conv.is_owned = false;
29611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29612         LDKChannelPublicKeys val_conv;
29613         val_conv.inner = (void*)(val & (~1));
29614         val_conv.is_owned = (val & 1) || (val == 0);
29615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29616         val_conv = ChannelPublicKeys_clone(&val_conv);
29617         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
29618 }
29619
29620 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
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         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
29626         return ret_val;
29627 }
29628
29629 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) {
29630         LDKChannelTransactionParameters this_ptr_conv;
29631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29632         this_ptr_conv.is_owned = false;
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29634         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
29635 }
29636
29637 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
29638         LDKChannelTransactionParameters this_ptr_conv;
29639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29640         this_ptr_conv.is_owned = false;
29641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29642         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
29643         return ret_val;
29644 }
29645
29646 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
29647         LDKChannelTransactionParameters this_ptr_conv;
29648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29649         this_ptr_conv.is_owned = false;
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29651         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
29652 }
29653
29654 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
29655         LDKChannelTransactionParameters this_ptr_conv;
29656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29657         this_ptr_conv.is_owned = false;
29658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29659         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
29660         uint64_t ret_ref = 0;
29661         if ((uint64_t)ret_var.inner > 4096) {
29662                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29663                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29665                 ret_ref = (uint64_t)ret_var.inner;
29666                 if (ret_var.is_owned) {
29667                         ret_ref |= 1;
29668                 }
29669         }
29670         return ret_ref;
29671 }
29672
29673 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
29674         LDKChannelTransactionParameters this_ptr_conv;
29675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29676         this_ptr_conv.is_owned = false;
29677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29678         LDKCounterpartyChannelTransactionParameters val_conv;
29679         val_conv.inner = (void*)(val & (~1));
29680         val_conv.is_owned = (val & 1) || (val == 0);
29681         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29682         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
29683         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
29684 }
29685
29686 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
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         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
29692         uint64_t ret_ref = 0;
29693         if ((uint64_t)ret_var.inner > 4096) {
29694                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29695                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29697                 ret_ref = (uint64_t)ret_var.inner;
29698                 if (ret_var.is_owned) {
29699                         ret_ref |= 1;
29700                 }
29701         }
29702         return ret_ref;
29703 }
29704
29705 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
29706         LDKChannelTransactionParameters this_ptr_conv;
29707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29708         this_ptr_conv.is_owned = false;
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29710         LDKOutPoint val_conv;
29711         val_conv.inner = (void*)(val & (~1));
29712         val_conv.is_owned = (val & 1) || (val == 0);
29713         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29714         val_conv = OutPoint_clone(&val_conv);
29715         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
29716 }
29717
29718 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
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         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
29724         return ret_conv;
29725 }
29726
29727 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
29728         LDKChannelTransactionParameters this_ptr_conv;
29729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29730         this_ptr_conv.is_owned = false;
29731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29732         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
29733         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
29734 }
29735
29736 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) {
29737         LDKChannelPublicKeys holder_pubkeys_arg_conv;
29738         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
29739         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
29741         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
29742         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
29743         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
29744         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
29745         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
29746         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
29747         LDKOutPoint funding_outpoint_arg_conv;
29748         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
29749         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
29750         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
29751         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
29752         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
29753         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);
29754         uint64_t ret_ref = 0;
29755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29758         ret_ref = (uint64_t)ret_var.inner;
29759         if (ret_var.is_owned) {
29760                 ret_ref |= 1;
29761         }
29762         return ret_ref;
29763 }
29764
29765 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
29766         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
29767 uint64_t ret_ref = 0;
29768 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29769 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29772 if (ret_var.is_owned) {
29773         ret_ref |= 1;
29774 }
29775         return ret_ref;
29776 }
29777 int64_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
29778         LDKChannelTransactionParameters arg_conv;
29779         arg_conv.inner = (void*)(arg & (~1));
29780         arg_conv.is_owned = false;
29781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29782         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
29783         return ret_val;
29784 }
29785
29786 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
29787         LDKChannelTransactionParameters orig_conv;
29788         orig_conv.inner = (void*)(orig & (~1));
29789         orig_conv.is_owned = false;
29790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29791         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
29792         uint64_t ret_ref = 0;
29793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29796         ret_ref = (uint64_t)ret_var.inner;
29797         if (ret_var.is_owned) {
29798                 ret_ref |= 1;
29799         }
29800         return ret_ref;
29801 }
29802
29803 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
29804         LDKCounterpartyChannelTransactionParameters this_obj_conv;
29805         this_obj_conv.inner = (void*)(this_obj & (~1));
29806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29808         CounterpartyChannelTransactionParameters_free(this_obj_conv);
29809 }
29810
29811 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
29812         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29814         this_ptr_conv.is_owned = false;
29815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29816         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
29817         uint64_t ret_ref = 0;
29818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29821         ret_ref = (uint64_t)ret_var.inner;
29822         if (ret_var.is_owned) {
29823                 ret_ref |= 1;
29824         }
29825         return ret_ref;
29826 }
29827
29828 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
29829         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29831         this_ptr_conv.is_owned = false;
29832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29833         LDKChannelPublicKeys val_conv;
29834         val_conv.inner = (void*)(val & (~1));
29835         val_conv.is_owned = (val & 1) || (val == 0);
29836         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29837         val_conv = ChannelPublicKeys_clone(&val_conv);
29838         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
29839 }
29840
29841 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
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         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
29847         return ret_val;
29848 }
29849
29850 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29851         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29853         this_ptr_conv.is_owned = false;
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29855         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
29856 }
29857
29858 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
29859         LDKChannelPublicKeys pubkeys_arg_conv;
29860         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
29861         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
29862         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
29863         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
29864         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
29865         uint64_t ret_ref = 0;
29866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29869         ret_ref = (uint64_t)ret_var.inner;
29870         if (ret_var.is_owned) {
29871                 ret_ref |= 1;
29872         }
29873         return ret_ref;
29874 }
29875
29876 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
29877         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
29878 uint64_t ret_ref = 0;
29879 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29880 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
29883 if (ret_var.is_owned) {
29884         ret_ref |= 1;
29885 }
29886         return ret_ref;
29887 }
29888 int64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
29889         LDKCounterpartyChannelTransactionParameters arg_conv;
29890         arg_conv.inner = (void*)(arg & (~1));
29891         arg_conv.is_owned = false;
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29893         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
29894         return ret_val;
29895 }
29896
29897 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
29898         LDKCounterpartyChannelTransactionParameters orig_conv;
29899         orig_conv.inner = (void*)(orig & (~1));
29900         orig_conv.is_owned = false;
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29902         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
29903         uint64_t ret_ref = 0;
29904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29907         ret_ref = (uint64_t)ret_var.inner;
29908         if (ret_var.is_owned) {
29909                 ret_ref |= 1;
29910         }
29911         return ret_ref;
29912 }
29913
29914 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
29915         LDKChannelTransactionParameters this_arg_conv;
29916         this_arg_conv.inner = (void*)(this_arg & (~1));
29917         this_arg_conv.is_owned = false;
29918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29919         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
29920         return ret_val;
29921 }
29922
29923 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
29924         LDKChannelTransactionParameters this_arg_conv;
29925         this_arg_conv.inner = (void*)(this_arg & (~1));
29926         this_arg_conv.is_owned = false;
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29928         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
29929         uint64_t ret_ref = 0;
29930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29933         ret_ref = (uint64_t)ret_var.inner;
29934         if (ret_var.is_owned) {
29935                 ret_ref |= 1;
29936         }
29937         return ret_ref;
29938 }
29939
29940 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
29941         LDKChannelTransactionParameters this_arg_conv;
29942         this_arg_conv.inner = (void*)(this_arg & (~1));
29943         this_arg_conv.is_owned = false;
29944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29945         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
29946         uint64_t ret_ref = 0;
29947         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29948         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29950         ret_ref = (uint64_t)ret_var.inner;
29951         if (ret_var.is_owned) {
29952                 ret_ref |= 1;
29953         }
29954         return ret_ref;
29955 }
29956
29957 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
29958         LDKCounterpartyChannelTransactionParameters obj_conv;
29959         obj_conv.inner = (void*)(obj & (~1));
29960         obj_conv.is_owned = false;
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29962         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
29963         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29964         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29965         CVec_u8Z_free(ret_var);
29966         return ret_arr;
29967 }
29968
29969 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
29970         LDKu8slice ser_ref;
29971         ser_ref.datalen = ser->arr_len;
29972         ser_ref.data = ser->elems;
29973         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
29974         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
29975         return (uint64_t)ret_conv;
29976 }
29977
29978 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
29979         LDKChannelTransactionParameters obj_conv;
29980         obj_conv.inner = (void*)(obj & (~1));
29981         obj_conv.is_owned = false;
29982         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29983         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
29984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
29985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29986         CVec_u8Z_free(ret_var);
29987         return ret_arr;
29988 }
29989
29990 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
29991         LDKu8slice ser_ref;
29992         ser_ref.datalen = ser->arr_len;
29993         ser_ref.data = ser->elems;
29994         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
29995         *ret_conv = ChannelTransactionParameters_read(ser_ref);
29996         return (uint64_t)ret_conv;
29997 }
29998
29999 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
30000         LDKDirectedChannelTransactionParameters this_obj_conv;
30001         this_obj_conv.inner = (void*)(this_obj & (~1));
30002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30004         DirectedChannelTransactionParameters_free(this_obj_conv);
30005 }
30006
30007 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
30008         LDKDirectedChannelTransactionParameters this_arg_conv;
30009         this_arg_conv.inner = (void*)(this_arg & (~1));
30010         this_arg_conv.is_owned = false;
30011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30012         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
30013         uint64_t ret_ref = 0;
30014         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30015         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30017         ret_ref = (uint64_t)ret_var.inner;
30018         if (ret_var.is_owned) {
30019                 ret_ref |= 1;
30020         }
30021         return ret_ref;
30022 }
30023
30024 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
30025         LDKDirectedChannelTransactionParameters this_arg_conv;
30026         this_arg_conv.inner = (void*)(this_arg & (~1));
30027         this_arg_conv.is_owned = false;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30029         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
30030         uint64_t ret_ref = 0;
30031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30034         ret_ref = (uint64_t)ret_var.inner;
30035         if (ret_var.is_owned) {
30036                 ret_ref |= 1;
30037         }
30038         return ret_ref;
30039 }
30040
30041 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
30042         LDKDirectedChannelTransactionParameters this_arg_conv;
30043         this_arg_conv.inner = (void*)(this_arg & (~1));
30044         this_arg_conv.is_owned = false;
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30046         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
30047         return ret_val;
30048 }
30049
30050 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
30051         LDKDirectedChannelTransactionParameters this_arg_conv;
30052         this_arg_conv.inner = (void*)(this_arg & (~1));
30053         this_arg_conv.is_owned = false;
30054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30055         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
30056         return ret_val;
30057 }
30058
30059 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
30060         LDKDirectedChannelTransactionParameters this_arg_conv;
30061         this_arg_conv.inner = (void*)(this_arg & (~1));
30062         this_arg_conv.is_owned = false;
30063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30064         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
30065         uint64_t ret_ref = 0;
30066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30069         ret_ref = (uint64_t)ret_var.inner;
30070         if (ret_var.is_owned) {
30071                 ret_ref |= 1;
30072         }
30073         return ret_ref;
30074 }
30075
30076 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
30077         LDKDirectedChannelTransactionParameters this_arg_conv;
30078         this_arg_conv.inner = (void*)(this_arg & (~1));
30079         this_arg_conv.is_owned = false;
30080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30081         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
30082         return ret_val;
30083 }
30084
30085 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
30086         LDKHolderCommitmentTransaction this_obj_conv;
30087         this_obj_conv.inner = (void*)(this_obj & (~1));
30088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30090         HolderCommitmentTransaction_free(this_obj_conv);
30091 }
30092
30093 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
30094         LDKHolderCommitmentTransaction this_ptr_conv;
30095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30096         this_ptr_conv.is_owned = false;
30097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30098         int8_tArray ret_arr = init_int8_tArray(64);
30099         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
30100         return ret_arr;
30101 }
30102
30103 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
30104         LDKHolderCommitmentTransaction this_ptr_conv;
30105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30106         this_ptr_conv.is_owned = false;
30107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30108         LDKSignature val_ref;
30109         CHECK(val->arr_len == 64);
30110         memcpy(val_ref.compact_form, val->elems, 64);
30111         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
30112 }
30113
30114 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
30115         LDKHolderCommitmentTransaction this_ptr_conv;
30116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30117         this_ptr_conv.is_owned = false;
30118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30119         LDKCVec_SignatureZ val_constr;
30120         val_constr.datalen = val->arr_len;
30121         if (val_constr.datalen > 0)
30122                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30123         else
30124                 val_constr.data = NULL;
30125         int8_tArray* val_vals = (void*) val->elems;
30126         for (size_t m = 0; m < val_constr.datalen; m++) {
30127                 int8_tArray val_conv_12 = val_vals[m];
30128                 LDKSignature val_conv_12_ref;
30129                 CHECK(val_conv_12->arr_len == 64);
30130                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64);
30131                 val_constr.data[m] = val_conv_12_ref;
30132         }
30133         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
30134 }
30135
30136 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
30137         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
30138 uint64_t ret_ref = 0;
30139 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30140 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30141 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30142 ret_ref = (uint64_t)ret_var.inner;
30143 if (ret_var.is_owned) {
30144         ret_ref |= 1;
30145 }
30146         return ret_ref;
30147 }
30148 int64_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
30149         LDKHolderCommitmentTransaction arg_conv;
30150         arg_conv.inner = (void*)(arg & (~1));
30151         arg_conv.is_owned = false;
30152         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30153         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
30154         return ret_val;
30155 }
30156
30157 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
30158         LDKHolderCommitmentTransaction orig_conv;
30159         orig_conv.inner = (void*)(orig & (~1));
30160         orig_conv.is_owned = false;
30161         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30162         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
30163         uint64_t ret_ref = 0;
30164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30167         ret_ref = (uint64_t)ret_var.inner;
30168         if (ret_var.is_owned) {
30169                 ret_ref |= 1;
30170         }
30171         return ret_ref;
30172 }
30173
30174 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
30175         LDKHolderCommitmentTransaction obj_conv;
30176         obj_conv.inner = (void*)(obj & (~1));
30177         obj_conv.is_owned = false;
30178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30179         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
30180         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30181         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30182         CVec_u8Z_free(ret_var);
30183         return ret_arr;
30184 }
30185
30186 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
30187         LDKu8slice ser_ref;
30188         ser_ref.datalen = ser->arr_len;
30189         ser_ref.data = ser->elems;
30190         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
30191         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
30192         return (uint64_t)ret_conv;
30193 }
30194
30195 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) {
30196         LDKCommitmentTransaction commitment_tx_conv;
30197         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
30198         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
30199         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
30200         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
30201         LDKSignature counterparty_sig_ref;
30202         CHECK(counterparty_sig->arr_len == 64);
30203         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64);
30204         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
30205         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
30206         if (counterparty_htlc_sigs_constr.datalen > 0)
30207                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30208         else
30209                 counterparty_htlc_sigs_constr.data = NULL;
30210         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
30211         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
30212                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
30213                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
30214                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
30215                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64);
30216                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
30217         }
30218         LDKPublicKey holder_funding_key_ref;
30219         CHECK(holder_funding_key->arr_len == 33);
30220         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33);
30221         LDKPublicKey counterparty_funding_key_ref;
30222         CHECK(counterparty_funding_key->arr_len == 33);
30223         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33);
30224         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
30225         uint64_t ret_ref = 0;
30226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30229         ret_ref = (uint64_t)ret_var.inner;
30230         if (ret_var.is_owned) {
30231                 ret_ref |= 1;
30232         }
30233         return ret_ref;
30234 }
30235
30236 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
30237         LDKBuiltCommitmentTransaction this_obj_conv;
30238         this_obj_conv.inner = (void*)(this_obj & (~1));
30239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30241         BuiltCommitmentTransaction_free(this_obj_conv);
30242 }
30243
30244 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
30245         LDKBuiltCommitmentTransaction this_ptr_conv;
30246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30247         this_ptr_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30249         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
30250         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30251         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30252         Transaction_free(ret_var);
30253         return ret_arr;
30254 }
30255
30256 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
30257         LDKBuiltCommitmentTransaction this_ptr_conv;
30258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30259         this_ptr_conv.is_owned = false;
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30261         LDKTransaction val_ref;
30262         val_ref.datalen = val->arr_len;
30263         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
30264         memcpy(val_ref.data, val->elems, val_ref.datalen);
30265         val_ref.data_is_owned = true;
30266         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
30267 }
30268
30269 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(32);
30275         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
30276         return ret_arr;
30277 }
30278
30279 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
30280         LDKBuiltCommitmentTransaction this_ptr_conv;
30281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30282         this_ptr_conv.is_owned = false;
30283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30284         LDKThirtyTwoBytes val_ref;
30285         CHECK(val->arr_len == 32);
30286         memcpy(val_ref.data, val->elems, 32);
30287         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
30288 }
30289
30290 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
30291         LDKTransaction transaction_arg_ref;
30292         transaction_arg_ref.datalen = transaction_arg->arr_len;
30293         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
30294         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen);
30295         transaction_arg_ref.data_is_owned = true;
30296         LDKThirtyTwoBytes txid_arg_ref;
30297         CHECK(txid_arg->arr_len == 32);
30298         memcpy(txid_arg_ref.data, txid_arg->elems, 32);
30299         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
30300         uint64_t ret_ref = 0;
30301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30304         ret_ref = (uint64_t)ret_var.inner;
30305         if (ret_var.is_owned) {
30306                 ret_ref |= 1;
30307         }
30308         return ret_ref;
30309 }
30310
30311 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
30312         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
30313 uint64_t ret_ref = 0;
30314 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30315 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
30318 if (ret_var.is_owned) {
30319         ret_ref |= 1;
30320 }
30321         return ret_ref;
30322 }
30323 int64_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
30324         LDKBuiltCommitmentTransaction arg_conv;
30325         arg_conv.inner = (void*)(arg & (~1));
30326         arg_conv.is_owned = false;
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30328         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
30329         return ret_val;
30330 }
30331
30332 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
30333         LDKBuiltCommitmentTransaction orig_conv;
30334         orig_conv.inner = (void*)(orig & (~1));
30335         orig_conv.is_owned = false;
30336         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30337         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
30338         uint64_t ret_ref = 0;
30339         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30340         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30342         ret_ref = (uint64_t)ret_var.inner;
30343         if (ret_var.is_owned) {
30344                 ret_ref |= 1;
30345         }
30346         return ret_ref;
30347 }
30348
30349 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
30350         LDKBuiltCommitmentTransaction obj_conv;
30351         obj_conv.inner = (void*)(obj & (~1));
30352         obj_conv.is_owned = false;
30353         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30354         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
30355         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30356         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30357         CVec_u8Z_free(ret_var);
30358         return ret_arr;
30359 }
30360
30361 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
30362         LDKu8slice ser_ref;
30363         ser_ref.datalen = ser->arr_len;
30364         ser_ref.data = ser->elems;
30365         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
30366         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
30367         return (uint64_t)ret_conv;
30368 }
30369
30370 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) {
30371         LDKBuiltCommitmentTransaction this_arg_conv;
30372         this_arg_conv.inner = (void*)(this_arg & (~1));
30373         this_arg_conv.is_owned = false;
30374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30375         LDKu8slice funding_redeemscript_ref;
30376         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30377         funding_redeemscript_ref.data = funding_redeemscript->elems;
30378         int8_tArray ret_arr = init_int8_tArray(32);
30379         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30380         return ret_arr;
30381 }
30382
30383 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) {
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         unsigned char funding_key_arr[32];
30389         CHECK(funding_key->arr_len == 32);
30390         memcpy(funding_key_arr, funding_key->elems, 32);
30391         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30392         LDKu8slice funding_redeemscript_ref;
30393         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30394         funding_redeemscript_ref.data = funding_redeemscript->elems;
30395         int8_tArray ret_arr = init_int8_tArray(64);
30396         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30397         return ret_arr;
30398 }
30399
30400 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
30401         LDKClosingTransaction this_obj_conv;
30402         this_obj_conv.inner = (void*)(this_obj & (~1));
30403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30405         ClosingTransaction_free(this_obj_conv);
30406 }
30407
30408 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
30409         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
30410 uint64_t ret_ref = 0;
30411 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30412 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30413 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30414 ret_ref = (uint64_t)ret_var.inner;
30415 if (ret_var.is_owned) {
30416         ret_ref |= 1;
30417 }
30418         return ret_ref;
30419 }
30420 int64_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
30421         LDKClosingTransaction arg_conv;
30422         arg_conv.inner = (void*)(arg & (~1));
30423         arg_conv.is_owned = false;
30424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30425         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
30426         return ret_val;
30427 }
30428
30429 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
30430         LDKClosingTransaction orig_conv;
30431         orig_conv.inner = (void*)(orig & (~1));
30432         orig_conv.is_owned = false;
30433         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30434         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
30435         uint64_t ret_ref = 0;
30436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30439         ret_ref = (uint64_t)ret_var.inner;
30440         if (ret_var.is_owned) {
30441                 ret_ref |= 1;
30442         }
30443         return ret_ref;
30444 }
30445
30446 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
30447         LDKClosingTransaction o_conv;
30448         o_conv.inner = (void*)(o & (~1));
30449         o_conv.is_owned = false;
30450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30451         int64_t ret_val = ClosingTransaction_hash(&o_conv);
30452         return ret_val;
30453 }
30454
30455 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) {
30456         LDKCVec_u8Z to_holder_script_ref;
30457         to_holder_script_ref.datalen = to_holder_script->arr_len;
30458         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
30459         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen);
30460         LDKCVec_u8Z to_counterparty_script_ref;
30461         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
30462         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
30463         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen);
30464         LDKOutPoint funding_outpoint_conv;
30465         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30466         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30468         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30469         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
30470         uint64_t ret_ref = 0;
30471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30474         ret_ref = (uint64_t)ret_var.inner;
30475         if (ret_var.is_owned) {
30476                 ret_ref |= 1;
30477         }
30478         return ret_ref;
30479 }
30480
30481 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
30482         LDKClosingTransaction this_arg_conv;
30483         this_arg_conv.inner = (void*)(this_arg & (~1));
30484         this_arg_conv.is_owned = false;
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30486         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
30487         uint64_t ret_ref = 0;
30488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30491         ret_ref = (uint64_t)ret_var.inner;
30492         if (ret_var.is_owned) {
30493                 ret_ref |= 1;
30494         }
30495         return ret_ref;
30496 }
30497
30498 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
30499         LDKClosingTransaction this_arg_conv;
30500         this_arg_conv.inner = (void*)(this_arg & (~1));
30501         this_arg_conv.is_owned = false;
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30503         LDKOutPoint funding_outpoint_conv;
30504         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30505         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30507         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30508         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
30509         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
30510         return (uint64_t)ret_conv;
30511 }
30512
30513 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
30514         LDKClosingTransaction this_arg_conv;
30515         this_arg_conv.inner = (void*)(this_arg & (~1));
30516         this_arg_conv.is_owned = false;
30517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30518         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
30519         return ret_val;
30520 }
30521
30522 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
30523         LDKClosingTransaction this_arg_conv;
30524         this_arg_conv.inner = (void*)(this_arg & (~1));
30525         this_arg_conv.is_owned = false;
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30527         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
30528         return ret_val;
30529 }
30530
30531 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
30532         LDKClosingTransaction this_arg_conv;
30533         this_arg_conv.inner = (void*)(this_arg & (~1));
30534         this_arg_conv.is_owned = false;
30535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30536         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
30537         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30538         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30539         return ret_arr;
30540 }
30541
30542 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
30543         LDKClosingTransaction this_arg_conv;
30544         this_arg_conv.inner = (void*)(this_arg & (~1));
30545         this_arg_conv.is_owned = false;
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30547         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
30548         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30549         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30550         return ret_arr;
30551 }
30552
30553 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
30554         LDKTrustedClosingTransaction this_obj_conv;
30555         this_obj_conv.inner = (void*)(this_obj & (~1));
30556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30558         TrustedClosingTransaction_free(this_obj_conv);
30559 }
30560
30561 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
30562         LDKTrustedClosingTransaction this_arg_conv;
30563         this_arg_conv.inner = (void*)(this_arg & (~1));
30564         this_arg_conv.is_owned = false;
30565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30566         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
30567         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30568         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30569         Transaction_free(ret_var);
30570         return ret_arr;
30571 }
30572
30573 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) {
30574         LDKTrustedClosingTransaction this_arg_conv;
30575         this_arg_conv.inner = (void*)(this_arg & (~1));
30576         this_arg_conv.is_owned = false;
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30578         LDKu8slice funding_redeemscript_ref;
30579         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30580         funding_redeemscript_ref.data = funding_redeemscript->elems;
30581         int8_tArray ret_arr = init_int8_tArray(32);
30582         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30583         return ret_arr;
30584 }
30585
30586 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) {
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         unsigned char funding_key_arr[32];
30592         CHECK(funding_key->arr_len == 32);
30593         memcpy(funding_key_arr, funding_key->elems, 32);
30594         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30595         LDKu8slice funding_redeemscript_ref;
30596         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30597         funding_redeemscript_ref.data = funding_redeemscript->elems;
30598         int8_tArray ret_arr = init_int8_tArray(64);
30599         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30600         return ret_arr;
30601 }
30602
30603 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
30604         LDKCommitmentTransaction this_obj_conv;
30605         this_obj_conv.inner = (void*)(this_obj & (~1));
30606         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30608         CommitmentTransaction_free(this_obj_conv);
30609 }
30610
30611 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
30612         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
30613 uint64_t ret_ref = 0;
30614 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30615 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30616 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30617 ret_ref = (uint64_t)ret_var.inner;
30618 if (ret_var.is_owned) {
30619         ret_ref |= 1;
30620 }
30621         return ret_ref;
30622 }
30623 int64_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
30624         LDKCommitmentTransaction arg_conv;
30625         arg_conv.inner = (void*)(arg & (~1));
30626         arg_conv.is_owned = false;
30627         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30628         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
30629         return ret_val;
30630 }
30631
30632 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
30633         LDKCommitmentTransaction orig_conv;
30634         orig_conv.inner = (void*)(orig & (~1));
30635         orig_conv.is_owned = false;
30636         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30637         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
30638         uint64_t ret_ref = 0;
30639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30642         ret_ref = (uint64_t)ret_var.inner;
30643         if (ret_var.is_owned) {
30644                 ret_ref |= 1;
30645         }
30646         return ret_ref;
30647 }
30648
30649 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
30650         LDKCommitmentTransaction obj_conv;
30651         obj_conv.inner = (void*)(obj & (~1));
30652         obj_conv.is_owned = false;
30653         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30654         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
30655         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
30656         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30657         CVec_u8Z_free(ret_var);
30658         return ret_arr;
30659 }
30660
30661 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
30662         LDKu8slice ser_ref;
30663         ser_ref.datalen = ser->arr_len;
30664         ser_ref.data = ser->elems;
30665         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
30666         *ret_conv = CommitmentTransaction_read(ser_ref);
30667         return (uint64_t)ret_conv;
30668 }
30669
30670 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
30671         LDKCommitmentTransaction this_arg_conv;
30672         this_arg_conv.inner = (void*)(this_arg & (~1));
30673         this_arg_conv.is_owned = false;
30674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30675         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
30676         return ret_val;
30677 }
30678
30679 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
30680         LDKCommitmentTransaction this_arg_conv;
30681         this_arg_conv.inner = (void*)(this_arg & (~1));
30682         this_arg_conv.is_owned = false;
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30684         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
30685         return ret_val;
30686 }
30687
30688 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
30689         LDKCommitmentTransaction this_arg_conv;
30690         this_arg_conv.inner = (void*)(this_arg & (~1));
30691         this_arg_conv.is_owned = false;
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30693         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
30694         return ret_val;
30695 }
30696
30697 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
30698         LDKCommitmentTransaction this_arg_conv;
30699         this_arg_conv.inner = (void*)(this_arg & (~1));
30700         this_arg_conv.is_owned = false;
30701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30702         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
30703         return ret_val;
30704 }
30705
30706 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
30707         LDKCommitmentTransaction this_arg_conv;
30708         this_arg_conv.inner = (void*)(this_arg & (~1));
30709         this_arg_conv.is_owned = false;
30710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30711         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
30712         uint64_t ret_ref = 0;
30713         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30714         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30716         ret_ref = (uint64_t)ret_var.inner;
30717         if (ret_var.is_owned) {
30718                 ret_ref |= 1;
30719         }
30720         return ret_ref;
30721 }
30722
30723 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) {
30724         LDKCommitmentTransaction this_arg_conv;
30725         this_arg_conv.inner = (void*)(this_arg & (~1));
30726         this_arg_conv.is_owned = false;
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30728         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30729         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30730         channel_parameters_conv.is_owned = false;
30731         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30732         LDKChannelPublicKeys broadcaster_keys_conv;
30733         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
30734         broadcaster_keys_conv.is_owned = false;
30735         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
30736         LDKChannelPublicKeys countersignatory_keys_conv;
30737         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
30738         countersignatory_keys_conv.is_owned = false;
30739         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
30740         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
30741         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
30742         return (uint64_t)ret_conv;
30743 }
30744
30745 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
30746         LDKTrustedCommitmentTransaction this_obj_conv;
30747         this_obj_conv.inner = (void*)(this_obj & (~1));
30748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30750         TrustedCommitmentTransaction_free(this_obj_conv);
30751 }
30752
30753 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
30754         LDKTrustedCommitmentTransaction this_arg_conv;
30755         this_arg_conv.inner = (void*)(this_arg & (~1));
30756         this_arg_conv.is_owned = false;
30757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30758         int8_tArray ret_arr = init_int8_tArray(32);
30759         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
30760         return ret_arr;
30761 }
30762
30763 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
30764         LDKTrustedCommitmentTransaction this_arg_conv;
30765         this_arg_conv.inner = (void*)(this_arg & (~1));
30766         this_arg_conv.is_owned = false;
30767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30768         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
30769         uint64_t ret_ref = 0;
30770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30773         ret_ref = (uint64_t)ret_var.inner;
30774         if (ret_var.is_owned) {
30775                 ret_ref |= 1;
30776         }
30777         return ret_ref;
30778 }
30779
30780 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
30781         LDKTrustedCommitmentTransaction this_arg_conv;
30782         this_arg_conv.inner = (void*)(this_arg & (~1));
30783         this_arg_conv.is_owned = false;
30784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30785         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
30786         uint64_t ret_ref = 0;
30787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30790         ret_ref = (uint64_t)ret_var.inner;
30791         if (ret_var.is_owned) {
30792                 ret_ref |= 1;
30793         }
30794         return ret_ref;
30795 }
30796
30797 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
30798         LDKTrustedCommitmentTransaction this_arg_conv;
30799         this_arg_conv.inner = (void*)(this_arg & (~1));
30800         this_arg_conv.is_owned = false;
30801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30802         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
30803         return ret_val;
30804 }
30805
30806 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) {
30807         LDKTrustedCommitmentTransaction this_arg_conv;
30808         this_arg_conv.inner = (void*)(this_arg & (~1));
30809         this_arg_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30811         unsigned char htlc_base_key_arr[32];
30812         CHECK(htlc_base_key->arr_len == 32);
30813         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32);
30814         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
30815         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30816         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30817         channel_parameters_conv.is_owned = false;
30818         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30819         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
30820         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
30821         return (uint64_t)ret_conv;
30822 }
30823
30824 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) {
30825         LDKPublicKey broadcaster_payment_basepoint_ref;
30826         CHECK(broadcaster_payment_basepoint->arr_len == 33);
30827         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33);
30828         LDKPublicKey countersignatory_payment_basepoint_ref;
30829         CHECK(countersignatory_payment_basepoint->arr_len == 33);
30830         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33);
30831         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
30832         return ret_val;
30833 }
30834
30835 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
30836         LDKInitFeatures a_conv;
30837         a_conv.inner = (void*)(a & (~1));
30838         a_conv.is_owned = false;
30839         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30840         LDKInitFeatures b_conv;
30841         b_conv.inner = (void*)(b & (~1));
30842         b_conv.is_owned = false;
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30844         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
30845         return ret_val;
30846 }
30847
30848 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
30849         LDKNodeFeatures 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         LDKNodeFeatures 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 = NodeFeatures_eq(&a_conv, &b_conv);
30858         return ret_val;
30859 }
30860
30861 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
30862         LDKChannelFeatures 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         LDKChannelFeatures 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 = ChannelFeatures_eq(&a_conv, &b_conv);
30871         return ret_val;
30872 }
30873
30874 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
30875         LDKInvoiceFeatures 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         LDKInvoiceFeatures 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 = InvoiceFeatures_eq(&a_conv, &b_conv);
30884         return ret_val;
30885 }
30886
30887 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
30888         LDKChannelTypeFeatures 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         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_eq(&a_conv, &b_conv);
30897         return ret_val;
30898 }
30899
30900 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
30901         LDKInitFeatures ret_var = InitFeatures_clone(arg);
30902 uint64_t ret_ref = 0;
30903 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30904 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30905 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30906 ret_ref = (uint64_t)ret_var.inner;
30907 if (ret_var.is_owned) {
30908         ret_ref |= 1;
30909 }
30910         return ret_ref;
30911 }
30912 int64_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
30913         LDKInitFeatures arg_conv;
30914         arg_conv.inner = (void*)(arg & (~1));
30915         arg_conv.is_owned = false;
30916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30917         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
30918         return ret_val;
30919 }
30920
30921 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
30922         LDKInitFeatures orig_conv;
30923         orig_conv.inner = (void*)(orig & (~1));
30924         orig_conv.is_owned = false;
30925         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30926         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
30927         uint64_t ret_ref = 0;
30928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30931         ret_ref = (uint64_t)ret_var.inner;
30932         if (ret_var.is_owned) {
30933                 ret_ref |= 1;
30934         }
30935         return ret_ref;
30936 }
30937
30938 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
30939         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
30940 uint64_t ret_ref = 0;
30941 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30942 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
30945 if (ret_var.is_owned) {
30946         ret_ref |= 1;
30947 }
30948         return ret_ref;
30949 }
30950 int64_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
30951         LDKNodeFeatures arg_conv;
30952         arg_conv.inner = (void*)(arg & (~1));
30953         arg_conv.is_owned = false;
30954         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30955         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
30956         return ret_val;
30957 }
30958
30959 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
30960         LDKNodeFeatures orig_conv;
30961         orig_conv.inner = (void*)(orig & (~1));
30962         orig_conv.is_owned = false;
30963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30964         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
30965         uint64_t ret_ref = 0;
30966         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30967         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30969         ret_ref = (uint64_t)ret_var.inner;
30970         if (ret_var.is_owned) {
30971                 ret_ref |= 1;
30972         }
30973         return ret_ref;
30974 }
30975
30976 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
30977         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
30978 uint64_t ret_ref = 0;
30979 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30980 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
30983 if (ret_var.is_owned) {
30984         ret_ref |= 1;
30985 }
30986         return ret_ref;
30987 }
30988 int64_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
30989         LDKChannelFeatures arg_conv;
30990         arg_conv.inner = (void*)(arg & (~1));
30991         arg_conv.is_owned = false;
30992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30993         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
30994         return ret_val;
30995 }
30996
30997 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
30998         LDKChannelFeatures orig_conv;
30999         orig_conv.inner = (void*)(orig & (~1));
31000         orig_conv.is_owned = false;
31001         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31002         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
31003         uint64_t ret_ref = 0;
31004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31007         ret_ref = (uint64_t)ret_var.inner;
31008         if (ret_var.is_owned) {
31009                 ret_ref |= 1;
31010         }
31011         return ret_ref;
31012 }
31013
31014 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
31015         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
31016 uint64_t ret_ref = 0;
31017 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31018 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31021 if (ret_var.is_owned) {
31022         ret_ref |= 1;
31023 }
31024         return ret_ref;
31025 }
31026 int64_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
31027         LDKInvoiceFeatures arg_conv;
31028         arg_conv.inner = (void*)(arg & (~1));
31029         arg_conv.is_owned = false;
31030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31031         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
31032         return ret_val;
31033 }
31034
31035 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
31036         LDKInvoiceFeatures orig_conv;
31037         orig_conv.inner = (void*)(orig & (~1));
31038         orig_conv.is_owned = false;
31039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31040         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
31041         uint64_t ret_ref = 0;
31042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31045         ret_ref = (uint64_t)ret_var.inner;
31046         if (ret_var.is_owned) {
31047                 ret_ref |= 1;
31048         }
31049         return ret_ref;
31050 }
31051
31052 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
31053         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
31054 uint64_t ret_ref = 0;
31055 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31056 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31059 if (ret_var.is_owned) {
31060         ret_ref |= 1;
31061 }
31062         return ret_ref;
31063 }
31064 int64_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
31065         LDKChannelTypeFeatures arg_conv;
31066         arg_conv.inner = (void*)(arg & (~1));
31067         arg_conv.is_owned = false;
31068         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31069         int64_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
31070         return ret_val;
31071 }
31072
31073 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
31074         LDKChannelTypeFeatures orig_conv;
31075         orig_conv.inner = (void*)(orig & (~1));
31076         orig_conv.is_owned = false;
31077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31078         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
31079         uint64_t ret_ref = 0;
31080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31083         ret_ref = (uint64_t)ret_var.inner;
31084         if (ret_var.is_owned) {
31085                 ret_ref |= 1;
31086         }
31087         return ret_ref;
31088 }
31089
31090 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
31091         LDKInitFeatures this_obj_conv;
31092         this_obj_conv.inner = (void*)(this_obj & (~1));
31093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31095         InitFeatures_free(this_obj_conv);
31096 }
31097
31098 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
31099         LDKNodeFeatures this_obj_conv;
31100         this_obj_conv.inner = (void*)(this_obj & (~1));
31101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31103         NodeFeatures_free(this_obj_conv);
31104 }
31105
31106 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
31107         LDKChannelFeatures this_obj_conv;
31108         this_obj_conv.inner = (void*)(this_obj & (~1));
31109         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31111         ChannelFeatures_free(this_obj_conv);
31112 }
31113
31114 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
31115         LDKInvoiceFeatures this_obj_conv;
31116         this_obj_conv.inner = (void*)(this_obj & (~1));
31117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31119         InvoiceFeatures_free(this_obj_conv);
31120 }
31121
31122 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
31123         LDKChannelTypeFeatures this_obj_conv;
31124         this_obj_conv.inner = (void*)(this_obj & (~1));
31125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31127         ChannelTypeFeatures_free(this_obj_conv);
31128 }
31129
31130 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
31131         LDKInitFeatures ret_var = InitFeatures_empty();
31132         uint64_t ret_ref = 0;
31133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31136         ret_ref = (uint64_t)ret_var.inner;
31137         if (ret_var.is_owned) {
31138                 ret_ref |= 1;
31139         }
31140         return ret_ref;
31141 }
31142
31143 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
31144         LDKInitFeatures ret_var = InitFeatures_known();
31145         uint64_t ret_ref = 0;
31146         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31147         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31150         if (ret_var.is_owned) {
31151                 ret_ref |= 1;
31152         }
31153         return ret_ref;
31154 }
31155
31156 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
31157         LDKInitFeatures this_arg_conv;
31158         this_arg_conv.inner = (void*)(this_arg & (~1));
31159         this_arg_conv.is_owned = false;
31160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31161         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
31162         return ret_val;
31163 }
31164
31165 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
31166         LDKNodeFeatures ret_var = NodeFeatures_empty();
31167         uint64_t ret_ref = 0;
31168         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31169         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31171         ret_ref = (uint64_t)ret_var.inner;
31172         if (ret_var.is_owned) {
31173                 ret_ref |= 1;
31174         }
31175         return ret_ref;
31176 }
31177
31178 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
31179         LDKNodeFeatures ret_var = NodeFeatures_known();
31180         uint64_t ret_ref = 0;
31181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31182         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31185         if (ret_var.is_owned) {
31186                 ret_ref |= 1;
31187         }
31188         return ret_ref;
31189 }
31190
31191 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
31192         LDKNodeFeatures this_arg_conv;
31193         this_arg_conv.inner = (void*)(this_arg & (~1));
31194         this_arg_conv.is_owned = false;
31195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31196         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
31197         return ret_val;
31198 }
31199
31200 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
31201         LDKChannelFeatures ret_var = ChannelFeatures_empty();
31202         uint64_t ret_ref = 0;
31203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31206         ret_ref = (uint64_t)ret_var.inner;
31207         if (ret_var.is_owned) {
31208                 ret_ref |= 1;
31209         }
31210         return ret_ref;
31211 }
31212
31213 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
31214         LDKChannelFeatures ret_var = ChannelFeatures_known();
31215         uint64_t ret_ref = 0;
31216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31217         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31220         if (ret_var.is_owned) {
31221                 ret_ref |= 1;
31222         }
31223         return ret_ref;
31224 }
31225
31226 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
31227         LDKChannelFeatures this_arg_conv;
31228         this_arg_conv.inner = (void*)(this_arg & (~1));
31229         this_arg_conv.is_owned = false;
31230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31231         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
31232         return ret_val;
31233 }
31234
31235 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
31236         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
31237         uint64_t ret_ref = 0;
31238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31241         ret_ref = (uint64_t)ret_var.inner;
31242         if (ret_var.is_owned) {
31243                 ret_ref |= 1;
31244         }
31245         return ret_ref;
31246 }
31247
31248 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
31249         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
31250         uint64_t ret_ref = 0;
31251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31252         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31255         if (ret_var.is_owned) {
31256                 ret_ref |= 1;
31257         }
31258         return ret_ref;
31259 }
31260
31261 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
31262         LDKInvoiceFeatures this_arg_conv;
31263         this_arg_conv.inner = (void*)(this_arg & (~1));
31264         this_arg_conv.is_owned = false;
31265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31266         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
31267         return ret_val;
31268 }
31269
31270 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
31271         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
31272         uint64_t ret_ref = 0;
31273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31276         ret_ref = (uint64_t)ret_var.inner;
31277         if (ret_var.is_owned) {
31278                 ret_ref |= 1;
31279         }
31280         return ret_ref;
31281 }
31282
31283 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
31284         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
31285         uint64_t ret_ref = 0;
31286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31287         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31290         if (ret_var.is_owned) {
31291                 ret_ref |= 1;
31292         }
31293         return ret_ref;
31294 }
31295
31296 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
31297         LDKChannelTypeFeatures this_arg_conv;
31298         this_arg_conv.inner = (void*)(this_arg & (~1));
31299         this_arg_conv.is_owned = false;
31300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31301         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
31302         return ret_val;
31303 }
31304
31305 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
31306         LDKInitFeatures obj_conv;
31307         obj_conv.inner = (void*)(obj & (~1));
31308         obj_conv.is_owned = false;
31309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31310         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
31311         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31312         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31313         CVec_u8Z_free(ret_var);
31314         return ret_arr;
31315 }
31316
31317 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
31318         LDKu8slice ser_ref;
31319         ser_ref.datalen = ser->arr_len;
31320         ser_ref.data = ser->elems;
31321         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
31322         *ret_conv = InitFeatures_read(ser_ref);
31323         return (uint64_t)ret_conv;
31324 }
31325
31326 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
31327         LDKChannelFeatures obj_conv;
31328         obj_conv.inner = (void*)(obj & (~1));
31329         obj_conv.is_owned = false;
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31331         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
31332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31334         CVec_u8Z_free(ret_var);
31335         return ret_arr;
31336 }
31337
31338 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
31339         LDKu8slice ser_ref;
31340         ser_ref.datalen = ser->arr_len;
31341         ser_ref.data = ser->elems;
31342         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
31343         *ret_conv = ChannelFeatures_read(ser_ref);
31344         return (uint64_t)ret_conv;
31345 }
31346
31347 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
31348         LDKNodeFeatures obj_conv;
31349         obj_conv.inner = (void*)(obj & (~1));
31350         obj_conv.is_owned = false;
31351         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31352         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
31353         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31354         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31355         CVec_u8Z_free(ret_var);
31356         return ret_arr;
31357 }
31358
31359 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
31360         LDKu8slice ser_ref;
31361         ser_ref.datalen = ser->arr_len;
31362         ser_ref.data = ser->elems;
31363         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
31364         *ret_conv = NodeFeatures_read(ser_ref);
31365         return (uint64_t)ret_conv;
31366 }
31367
31368 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
31369         LDKInvoiceFeatures obj_conv;
31370         obj_conv.inner = (void*)(obj & (~1));
31371         obj_conv.is_owned = false;
31372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31373         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
31374         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31375         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31376         CVec_u8Z_free(ret_var);
31377         return ret_arr;
31378 }
31379
31380 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
31381         LDKu8slice ser_ref;
31382         ser_ref.datalen = ser->arr_len;
31383         ser_ref.data = ser->elems;
31384         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
31385         *ret_conv = InvoiceFeatures_read(ser_ref);
31386         return (uint64_t)ret_conv;
31387 }
31388
31389 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
31390         LDKChannelTypeFeatures obj_conv;
31391         obj_conv.inner = (void*)(obj & (~1));
31392         obj_conv.is_owned = false;
31393         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31394         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
31395         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31396         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31397         CVec_u8Z_free(ret_var);
31398         return ret_arr;
31399 }
31400
31401 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
31402         LDKu8slice ser_ref;
31403         ser_ref.datalen = ser->arr_len;
31404         ser_ref.data = ser->elems;
31405         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
31406         *ret_conv = ChannelTypeFeatures_read(ser_ref);
31407         return (uint64_t)ret_conv;
31408 }
31409
31410 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
31411         LDKShutdownScript this_obj_conv;
31412         this_obj_conv.inner = (void*)(this_obj & (~1));
31413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31415         ShutdownScript_free(this_obj_conv);
31416 }
31417
31418 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
31419         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
31420 uint64_t ret_ref = 0;
31421 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31422 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31423 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31424 ret_ref = (uint64_t)ret_var.inner;
31425 if (ret_var.is_owned) {
31426         ret_ref |= 1;
31427 }
31428         return ret_ref;
31429 }
31430 int64_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
31431         LDKShutdownScript arg_conv;
31432         arg_conv.inner = (void*)(arg & (~1));
31433         arg_conv.is_owned = false;
31434         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31435         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
31436         return ret_val;
31437 }
31438
31439 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
31440         LDKShutdownScript orig_conv;
31441         orig_conv.inner = (void*)(orig & (~1));
31442         orig_conv.is_owned = false;
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31444         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
31445         uint64_t ret_ref = 0;
31446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31449         ret_ref = (uint64_t)ret_var.inner;
31450         if (ret_var.is_owned) {
31451                 ret_ref |= 1;
31452         }
31453         return ret_ref;
31454 }
31455
31456 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
31457         LDKInvalidShutdownScript this_obj_conv;
31458         this_obj_conv.inner = (void*)(this_obj & (~1));
31459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31461         InvalidShutdownScript_free(this_obj_conv);
31462 }
31463
31464 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
31465         LDKInvalidShutdownScript this_ptr_conv;
31466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31467         this_ptr_conv.is_owned = false;
31468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31469         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
31470         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31471         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31472         return ret_arr;
31473 }
31474
31475 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
31476         LDKInvalidShutdownScript this_ptr_conv;
31477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31478         this_ptr_conv.is_owned = false;
31479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31480         LDKCVec_u8Z val_ref;
31481         val_ref.datalen = val->arr_len;
31482         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31483         memcpy(val_ref.data, val->elems, val_ref.datalen);
31484         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
31485 }
31486
31487 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
31488         LDKCVec_u8Z script_arg_ref;
31489         script_arg_ref.datalen = script_arg->arr_len;
31490         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31491         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen);
31492         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
31493         uint64_t ret_ref = 0;
31494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31497         ret_ref = (uint64_t)ret_var.inner;
31498         if (ret_var.is_owned) {
31499                 ret_ref |= 1;
31500         }
31501         return ret_ref;
31502 }
31503
31504 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
31505         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
31506 uint64_t ret_ref = 0;
31507 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31508 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31511 if (ret_var.is_owned) {
31512         ret_ref |= 1;
31513 }
31514         return ret_ref;
31515 }
31516 int64_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
31517         LDKInvalidShutdownScript arg_conv;
31518         arg_conv.inner = (void*)(arg & (~1));
31519         arg_conv.is_owned = false;
31520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31521         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
31522         return ret_val;
31523 }
31524
31525 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
31526         LDKInvalidShutdownScript orig_conv;
31527         orig_conv.inner = (void*)(orig & (~1));
31528         orig_conv.is_owned = false;
31529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31530         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
31531         uint64_t ret_ref = 0;
31532         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31533         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31535         ret_ref = (uint64_t)ret_var.inner;
31536         if (ret_var.is_owned) {
31537                 ret_ref |= 1;
31538         }
31539         return ret_ref;
31540 }
31541
31542 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
31543         LDKShutdownScript obj_conv;
31544         obj_conv.inner = (void*)(obj & (~1));
31545         obj_conv.is_owned = false;
31546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31547         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
31548         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31549         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31550         CVec_u8Z_free(ret_var);
31551         return ret_arr;
31552 }
31553
31554 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
31555         LDKu8slice ser_ref;
31556         ser_ref.datalen = ser->arr_len;
31557         ser_ref.data = ser->elems;
31558         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
31559         *ret_conv = ShutdownScript_read(ser_ref);
31560         return (uint64_t)ret_conv;
31561 }
31562
31563 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
31564         unsigned char pubkey_hash_arr[20];
31565         CHECK(pubkey_hash->arr_len == 20);
31566         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20);
31567         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
31568         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
31569         uint64_t ret_ref = 0;
31570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31573         ret_ref = (uint64_t)ret_var.inner;
31574         if (ret_var.is_owned) {
31575                 ret_ref |= 1;
31576         }
31577         return ret_ref;
31578 }
31579
31580 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
31581         unsigned char script_hash_arr[32];
31582         CHECK(script_hash->arr_len == 32);
31583         memcpy(script_hash_arr, script_hash->elems, 32);
31584         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
31585         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
31586         uint64_t ret_ref = 0;
31587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31590         ret_ref = (uint64_t)ret_var.inner;
31591         if (ret_var.is_owned) {
31592                 ret_ref |= 1;
31593         }
31594         return ret_ref;
31595 }
31596
31597 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
31598         LDKu8slice program_ref;
31599         program_ref.datalen = program->arr_len;
31600         program_ref.data = program->elems;
31601         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
31602         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
31603         return (uint64_t)ret_conv;
31604 }
31605
31606 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
31607         LDKShutdownScript this_arg_conv;
31608         this_arg_conv.inner = (void*)(this_arg & (~1));
31609         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31611         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
31612         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
31613         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31614         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31615         CVec_u8Z_free(ret_var);
31616         return ret_arr;
31617 }
31618
31619 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
31620         LDKShutdownScript this_arg_conv;
31621         this_arg_conv.inner = (void*)(this_arg & (~1));
31622         this_arg_conv.is_owned = false;
31623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31624         int8_tArray ret_arr = init_int8_tArray(33);
31625         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
31626         return ret_arr;
31627 }
31628
31629 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
31630         LDKShutdownScript this_arg_conv;
31631         this_arg_conv.inner = (void*)(this_arg & (~1));
31632         this_arg_conv.is_owned = false;
31633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31634         LDKInitFeatures features_conv;
31635         features_conv.inner = (void*)(features & (~1));
31636         features_conv.is_owned = false;
31637         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
31638         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
31639         return ret_val;
31640 }
31641
31642 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
31643         if ((this_ptr & 1) != 0) return;
31644         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31645         CHECK_ACCESS(this_ptr_ptr);
31646         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
31647         FREE((void*)this_ptr);
31648         CustomMessageReader_free(this_ptr_conv);
31649 }
31650
31651 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
31652         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31653         *ret_ret = Type_clone(arg);
31654         return (uint64_t)ret_ret;
31655 }
31656 int64_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
31657         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
31658         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31659         LDKType* arg_conv = (LDKType*)arg_ptr;
31660         int64_t ret_val = Type_clone_ptr(arg_conv);
31661         return ret_val;
31662 }
31663
31664 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
31665         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
31666         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31667         LDKType* orig_conv = (LDKType*)orig_ptr;
31668         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31669         *ret_ret = Type_clone(orig_conv);
31670         return (uint64_t)ret_ret;
31671 }
31672
31673 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
31674         if ((this_ptr & 1) != 0) return;
31675         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31676         CHECK_ACCESS(this_ptr_ptr);
31677         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
31678         FREE((void*)this_ptr);
31679         Type_free(this_ptr_conv);
31680 }
31681
31682 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
31683         LDKNodeId this_obj_conv;
31684         this_obj_conv.inner = (void*)(this_obj & (~1));
31685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31687         NodeId_free(this_obj_conv);
31688 }
31689
31690 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
31691         LDKNodeId ret_var = NodeId_clone(arg);
31692 uint64_t ret_ref = 0;
31693 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31694 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31695 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31696 ret_ref = (uint64_t)ret_var.inner;
31697 if (ret_var.is_owned) {
31698         ret_ref |= 1;
31699 }
31700         return ret_ref;
31701 }
31702 int64_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
31703         LDKNodeId arg_conv;
31704         arg_conv.inner = (void*)(arg & (~1));
31705         arg_conv.is_owned = false;
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31707         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
31708         return ret_val;
31709 }
31710
31711 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
31712         LDKNodeId orig_conv;
31713         orig_conv.inner = (void*)(orig & (~1));
31714         orig_conv.is_owned = false;
31715         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31716         LDKNodeId ret_var = NodeId_clone(&orig_conv);
31717         uint64_t ret_ref = 0;
31718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31721         ret_ref = (uint64_t)ret_var.inner;
31722         if (ret_var.is_owned) {
31723                 ret_ref |= 1;
31724         }
31725         return ret_ref;
31726 }
31727
31728 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
31729         LDKPublicKey pubkey_ref;
31730         CHECK(pubkey->arr_len == 33);
31731         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33);
31732         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
31733         uint64_t ret_ref = 0;
31734         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31735         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31737         ret_ref = (uint64_t)ret_var.inner;
31738         if (ret_var.is_owned) {
31739                 ret_ref |= 1;
31740         }
31741         return ret_ref;
31742 }
31743
31744 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
31745         LDKNodeId this_arg_conv;
31746         this_arg_conv.inner = (void*)(this_arg & (~1));
31747         this_arg_conv.is_owned = false;
31748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31749         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
31750         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31751         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31752         return ret_arr;
31753 }
31754
31755 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
31756         LDKNodeId o_conv;
31757         o_conv.inner = (void*)(o & (~1));
31758         o_conv.is_owned = false;
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
31760         int64_t ret_val = NodeId_hash(&o_conv);
31761         return ret_val;
31762 }
31763
31764 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
31765         LDKNodeId obj_conv;
31766         obj_conv.inner = (void*)(obj & (~1));
31767         obj_conv.is_owned = false;
31768         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31769         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
31770         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31771         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31772         CVec_u8Z_free(ret_var);
31773         return ret_arr;
31774 }
31775
31776 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
31777         LDKu8slice ser_ref;
31778         ser_ref.datalen = ser->arr_len;
31779         ser_ref.data = ser->elems;
31780         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
31781         *ret_conv = NodeId_read(ser_ref);
31782         return (uint64_t)ret_conv;
31783 }
31784
31785 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
31786         LDKNetworkGraph this_obj_conv;
31787         this_obj_conv.inner = (void*)(this_obj & (~1));
31788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31790         NetworkGraph_free(this_obj_conv);
31791 }
31792
31793 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
31794         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
31795 uint64_t ret_ref = 0;
31796 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31797 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31799 ret_ref = (uint64_t)ret_var.inner;
31800 if (ret_var.is_owned) {
31801         ret_ref |= 1;
31802 }
31803         return ret_ref;
31804 }
31805 int64_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
31806         LDKNetworkGraph arg_conv;
31807         arg_conv.inner = (void*)(arg & (~1));
31808         arg_conv.is_owned = false;
31809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31810         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
31811         return ret_val;
31812 }
31813
31814 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
31815         LDKNetworkGraph orig_conv;
31816         orig_conv.inner = (void*)(orig & (~1));
31817         orig_conv.is_owned = false;
31818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31819         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
31820         uint64_t ret_ref = 0;
31821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31824         ret_ref = (uint64_t)ret_var.inner;
31825         if (ret_var.is_owned) {
31826                 ret_ref |= 1;
31827         }
31828         return ret_ref;
31829 }
31830
31831 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
31832         LDKReadOnlyNetworkGraph this_obj_conv;
31833         this_obj_conv.inner = (void*)(this_obj & (~1));
31834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31836         ReadOnlyNetworkGraph_free(this_obj_conv);
31837 }
31838
31839 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
31840         if ((this_ptr & 1) != 0) return;
31841         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31842         CHECK_ACCESS(this_ptr_ptr);
31843         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
31844         FREE((void*)this_ptr);
31845         NetworkUpdate_free(this_ptr_conv);
31846 }
31847
31848 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
31849         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31850         *ret_copy = NetworkUpdate_clone(arg);
31851 uint64_t ret_ref = (uint64_t)ret_copy;
31852         return ret_ref;
31853 }
31854 int64_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
31855         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
31856         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
31857         return ret_val;
31858 }
31859
31860 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
31861         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
31862         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31863         *ret_copy = NetworkUpdate_clone(orig_conv);
31864         uint64_t ret_ref = (uint64_t)ret_copy;
31865         return ret_ref;
31866 }
31867
31868 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
31869         LDKChannelUpdate msg_conv;
31870         msg_conv.inner = (void*)(msg & (~1));
31871         msg_conv.is_owned = (msg & 1) || (msg == 0);
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31873         msg_conv = ChannelUpdate_clone(&msg_conv);
31874         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31875         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
31876         uint64_t ret_ref = (uint64_t)ret_copy;
31877         return ret_ref;
31878 }
31879
31880 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
31881         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31882         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
31883         uint64_t ret_ref = (uint64_t)ret_copy;
31884         return ret_ref;
31885 }
31886
31887 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
31888         LDKPublicKey node_id_ref;
31889         CHECK(node_id->arr_len == 33);
31890         memcpy(node_id_ref.compressed_form, node_id->elems, 33);
31891         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31892         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
31893         uint64_t ret_ref = (uint64_t)ret_copy;
31894         return ret_ref;
31895 }
31896
31897 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
31898         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
31899         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
31900         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
31901         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31902         CVec_u8Z_free(ret_var);
31903         return ret_arr;
31904 }
31905
31906 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
31907         LDKu8slice ser_ref;
31908         ser_ref.datalen = ser->arr_len;
31909         ser_ref.data = ser->elems;
31910         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
31911         *ret_conv = NetworkUpdate_read(ser_ref);
31912         return (uint64_t)ret_conv;
31913 }
31914
31915 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
31916         LDKNetGraphMsgHandler this_arg_conv;
31917         this_arg_conv.inner = (void*)(this_arg & (~1));
31918         this_arg_conv.is_owned = false;
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31920         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
31921         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
31922         return (uint64_t)ret_ret;
31923 }
31924
31925 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
31926         LDKNetGraphMsgHandler this_obj_conv;
31927         this_obj_conv.inner = (void*)(this_obj & (~1));
31928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31930         NetGraphMsgHandler_free(this_obj_conv);
31931 }
31932
31933 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
31934         LDKNetworkGraph network_graph_conv;
31935         network_graph_conv.inner = (void*)(network_graph & (~1));
31936         network_graph_conv.is_owned = false;
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
31938         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
31939         CHECK_ACCESS(chain_access_ptr);
31940         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31941         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31942         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31943                 // Manually implement clone for Java trait instances
31944         }
31945         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
31946         CHECK_ACCESS(logger_ptr);
31947         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31948         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
31949         uint64_t ret_ref = 0;
31950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31953         ret_ref = (uint64_t)ret_var.inner;
31954         if (ret_var.is_owned) {
31955                 ret_ref |= 1;
31956         }
31957         return ret_ref;
31958 }
31959
31960 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
31961         LDKNetGraphMsgHandler this_arg_conv;
31962         this_arg_conv.inner = (void*)(this_arg & (~1));
31963         this_arg_conv.is_owned = false;
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31965         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
31966         CHECK_ACCESS(chain_access_ptr);
31967         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31968         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31969         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31970                 // Manually implement clone for Java trait instances
31971         }
31972         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
31973 }
31974
31975 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31976         LDKNetGraphMsgHandler this_arg_conv;
31977         this_arg_conv.inner = (void*)(this_arg & (~1));
31978         this_arg_conv.is_owned = false;
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31980         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31981         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
31982         return (uint64_t)ret_ret;
31983 }
31984
31985 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31986         LDKNetGraphMsgHandler this_arg_conv;
31987         this_arg_conv.inner = (void*)(this_arg & (~1));
31988         this_arg_conv.is_owned = false;
31989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31990         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31991         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
31992         return (uint64_t)ret_ret;
31993 }
31994
31995 void  __attribute__((export_name("TS_DirectionalChannelInfo_free"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
31996         LDKDirectionalChannelInfo this_obj_conv;
31997         this_obj_conv.inner = (void*)(this_obj & (~1));
31998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32000         DirectionalChannelInfo_free(this_obj_conv);
32001 }
32002
32003 int32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
32004         LDKDirectionalChannelInfo this_ptr_conv;
32005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32006         this_ptr_conv.is_owned = false;
32007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32008         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
32009         return ret_val;
32010 }
32011
32012 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32013         LDKDirectionalChannelInfo this_ptr_conv;
32014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32015         this_ptr_conv.is_owned = false;
32016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32017         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
32018 }
32019
32020 jboolean  __attribute__((export_name("TS_DirectionalChannelInfo_get_enabled"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
32021         LDKDirectionalChannelInfo this_ptr_conv;
32022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32023         this_ptr_conv.is_owned = false;
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32025         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
32026         return ret_val;
32027 }
32028
32029 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_enabled"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
32030         LDKDirectionalChannelInfo this_ptr_conv;
32031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32032         this_ptr_conv.is_owned = false;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32034         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
32035 }
32036
32037 int16_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_cltv_expiry_delta"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
32038         LDKDirectionalChannelInfo this_ptr_conv;
32039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32040         this_ptr_conv.is_owned = false;
32041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32042         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
32043         return ret_val;
32044 }
32045
32046 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_cltv_expiry_delta"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32047         LDKDirectionalChannelInfo this_ptr_conv;
32048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32049         this_ptr_conv.is_owned = false;
32050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32051         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
32052 }
32053
32054 int64_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_minimum_msat"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
32055         LDKDirectionalChannelInfo this_ptr_conv;
32056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32057         this_ptr_conv.is_owned = false;
32058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32059         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
32060         return ret_val;
32061 }
32062
32063 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_minimum_msat"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32064         LDKDirectionalChannelInfo this_ptr_conv;
32065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32066         this_ptr_conv.is_owned = false;
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32068         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
32069 }
32070
32071 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_maximum_msat"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
32072         LDKDirectionalChannelInfo this_ptr_conv;
32073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32074         this_ptr_conv.is_owned = false;
32075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32076         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32077         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
32078         uint64_t ret_ref = (uint64_t)ret_copy;
32079         return ret_ref;
32080 }
32081
32082 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_maximum_msat"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
32083         LDKDirectionalChannelInfo this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32088         CHECK_ACCESS(val_ptr);
32089         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32090         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
32091         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
32092 }
32093
32094 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_fees"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
32095         LDKDirectionalChannelInfo this_ptr_conv;
32096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32097         this_ptr_conv.is_owned = false;
32098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32099         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
32100         uint64_t ret_ref = 0;
32101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32104         ret_ref = (uint64_t)ret_var.inner;
32105         if (ret_var.is_owned) {
32106                 ret_ref |= 1;
32107         }
32108         return ret_ref;
32109 }
32110
32111 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_fees"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
32112         LDKDirectionalChannelInfo this_ptr_conv;
32113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32114         this_ptr_conv.is_owned = false;
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32116         LDKRoutingFees val_conv;
32117         val_conv.inner = (void*)(val & (~1));
32118         val_conv.is_owned = (val & 1) || (val == 0);
32119         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32120         val_conv = RoutingFees_clone(&val_conv);
32121         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
32122 }
32123
32124 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update_message"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
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         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
32130         uint64_t ret_ref = 0;
32131         if ((uint64_t)ret_var.inner > 4096) {
32132                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32133                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32135                 ret_ref = (uint64_t)ret_var.inner;
32136                 if (ret_var.is_owned) {
32137                         ret_ref |= 1;
32138                 }
32139         }
32140         return ret_ref;
32141 }
32142
32143 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update_message"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
32144         LDKDirectionalChannelInfo this_ptr_conv;
32145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32146         this_ptr_conv.is_owned = false;
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32148         LDKChannelUpdate val_conv;
32149         val_conv.inner = (void*)(val & (~1));
32150         val_conv.is_owned = (val & 1) || (val == 0);
32151         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32152         val_conv = ChannelUpdate_clone(&val_conv);
32153         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
32154 }
32155
32156 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) {
32157         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
32158         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
32159         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
32160         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
32161         LDKRoutingFees fees_arg_conv;
32162         fees_arg_conv.inner = (void*)(fees_arg & (~1));
32163         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
32164         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
32165         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
32166         LDKChannelUpdate last_update_message_arg_conv;
32167         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
32168         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
32169         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
32170         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
32171         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);
32172         uint64_t ret_ref = 0;
32173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32176         ret_ref = (uint64_t)ret_var.inner;
32177         if (ret_var.is_owned) {
32178                 ret_ref |= 1;
32179         }
32180         return ret_ref;
32181 }
32182
32183 static inline uintptr_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
32184         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
32185 uint64_t ret_ref = 0;
32186 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32187 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
32190 if (ret_var.is_owned) {
32191         ret_ref |= 1;
32192 }
32193         return ret_ref;
32194 }
32195 int64_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone_ptr"))) TS_DirectionalChannelInfo_clone_ptr(uint32_t arg) {
32196         LDKDirectionalChannelInfo arg_conv;
32197         arg_conv.inner = (void*)(arg & (~1));
32198         arg_conv.is_owned = false;
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32200         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
32201         return ret_val;
32202 }
32203
32204 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
32205         LDKDirectionalChannelInfo orig_conv;
32206         orig_conv.inner = (void*)(orig & (~1));
32207         orig_conv.is_owned = false;
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32209         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
32210         uint64_t ret_ref = 0;
32211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32214         ret_ref = (uint64_t)ret_var.inner;
32215         if (ret_var.is_owned) {
32216                 ret_ref |= 1;
32217         }
32218         return ret_ref;
32219 }
32220
32221 int8_tArray  __attribute__((export_name("TS_DirectionalChannelInfo_write"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
32222         LDKDirectionalChannelInfo obj_conv;
32223         obj_conv.inner = (void*)(obj & (~1));
32224         obj_conv.is_owned = false;
32225         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32226         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
32227         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
32228         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32229         CVec_u8Z_free(ret_var);
32230         return ret_arr;
32231 }
32232
32233 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_read"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
32234         LDKu8slice ser_ref;
32235         ser_ref.datalen = ser->arr_len;
32236         ser_ref.data = ser->elems;
32237         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
32238         *ret_conv = DirectionalChannelInfo_read(ser_ref);
32239         return (uint64_t)ret_conv;
32240 }
32241
32242 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
32243         LDKChannelInfo this_obj_conv;
32244         this_obj_conv.inner = (void*)(this_obj & (~1));
32245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32247         ChannelInfo_free(this_obj_conv);
32248 }
32249
32250 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
32251         LDKChannelInfo this_ptr_conv;
32252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32253         this_ptr_conv.is_owned = false;
32254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32255         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
32256         uint64_t ret_ref = 0;
32257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32260         ret_ref = (uint64_t)ret_var.inner;
32261         if (ret_var.is_owned) {
32262                 ret_ref |= 1;
32263         }
32264         return ret_ref;
32265 }
32266
32267 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
32268         LDKChannelInfo this_ptr_conv;
32269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32270         this_ptr_conv.is_owned = false;
32271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32272         LDKChannelFeatures val_conv;
32273         val_conv.inner = (void*)(val & (~1));
32274         val_conv.is_owned = (val & 1) || (val == 0);
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32276         val_conv = ChannelFeatures_clone(&val_conv);
32277         ChannelInfo_set_features(&this_ptr_conv, val_conv);
32278 }
32279
32280 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
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         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
32286         uint64_t ret_ref = 0;
32287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32290         ret_ref = (uint64_t)ret_var.inner;
32291         if (ret_var.is_owned) {
32292                 ret_ref |= 1;
32293         }
32294         return ret_ref;
32295 }
32296
32297 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
32298         LDKChannelInfo this_ptr_conv;
32299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32300         this_ptr_conv.is_owned = false;
32301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32302         LDKNodeId val_conv;
32303         val_conv.inner = (void*)(val & (~1));
32304         val_conv.is_owned = (val & 1) || (val == 0);
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32306         val_conv = NodeId_clone(&val_conv);
32307         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
32308 }
32309
32310 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
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         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
32316         uint64_t ret_ref = 0;
32317         if ((uint64_t)ret_var.inner > 4096) {
32318                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32319                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32321                 ret_ref = (uint64_t)ret_var.inner;
32322                 if (ret_var.is_owned) {
32323                         ret_ref |= 1;
32324                 }
32325         }
32326         return ret_ref;
32327 }
32328
32329 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
32330         LDKChannelInfo this_ptr_conv;
32331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32332         this_ptr_conv.is_owned = false;
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32334         LDKDirectionalChannelInfo val_conv;
32335         val_conv.inner = (void*)(val & (~1));
32336         val_conv.is_owned = (val & 1) || (val == 0);
32337         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32338         val_conv = DirectionalChannelInfo_clone(&val_conv);
32339         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
32340 }
32341
32342 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
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         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
32348         uint64_t ret_ref = 0;
32349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32352         ret_ref = (uint64_t)ret_var.inner;
32353         if (ret_var.is_owned) {
32354                 ret_ref |= 1;
32355         }
32356         return ret_ref;
32357 }
32358
32359 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
32360         LDKChannelInfo this_ptr_conv;
32361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32362         this_ptr_conv.is_owned = false;
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32364         LDKNodeId val_conv;
32365         val_conv.inner = (void*)(val & (~1));
32366         val_conv.is_owned = (val & 1) || (val == 0);
32367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32368         val_conv = NodeId_clone(&val_conv);
32369         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
32370 }
32371
32372 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
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         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
32378         uint64_t ret_ref = 0;
32379         if ((uint64_t)ret_var.inner > 4096) {
32380                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32381                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32383                 ret_ref = (uint64_t)ret_var.inner;
32384                 if (ret_var.is_owned) {
32385                         ret_ref |= 1;
32386                 }
32387         }
32388         return ret_ref;
32389 }
32390
32391 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
32392         LDKChannelInfo this_ptr_conv;
32393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32394         this_ptr_conv.is_owned = false;
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         LDKDirectionalChannelInfo val_conv;
32397         val_conv.inner = (void*)(val & (~1));
32398         val_conv.is_owned = (val & 1) || (val == 0);
32399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32400         val_conv = DirectionalChannelInfo_clone(&val_conv);
32401         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
32402 }
32403
32404 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32410         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
32411         uint64_t ret_ref = (uint64_t)ret_copy;
32412         return ret_ref;
32413 }
32414
32415 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
32416         LDKChannelInfo this_ptr_conv;
32417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32418         this_ptr_conv.is_owned = false;
32419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32420         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32421         CHECK_ACCESS(val_ptr);
32422         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32423         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
32424         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
32425 }
32426
32427 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
32428         LDKChannelInfo this_ptr_conv;
32429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32430         this_ptr_conv.is_owned = false;
32431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32432         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
32433         uint64_t ret_ref = 0;
32434         if ((uint64_t)ret_var.inner > 4096) {
32435                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32436                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32438                 ret_ref = (uint64_t)ret_var.inner;
32439                 if (ret_var.is_owned) {
32440                         ret_ref |= 1;
32441                 }
32442         }
32443         return ret_ref;
32444 }
32445
32446 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32447         LDKChannelInfo this_ptr_conv;
32448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32449         this_ptr_conv.is_owned = false;
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32451         LDKChannelAnnouncement val_conv;
32452         val_conv.inner = (void*)(val & (~1));
32453         val_conv.is_owned = (val & 1) || (val == 0);
32454         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32455         val_conv = ChannelAnnouncement_clone(&val_conv);
32456         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
32457 }
32458
32459 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
32460         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
32461 uint64_t ret_ref = 0;
32462 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32463 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32464 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32465 ret_ref = (uint64_t)ret_var.inner;
32466 if (ret_var.is_owned) {
32467         ret_ref |= 1;
32468 }
32469         return ret_ref;
32470 }
32471 int64_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
32472         LDKChannelInfo arg_conv;
32473         arg_conv.inner = (void*)(arg & (~1));
32474         arg_conv.is_owned = false;
32475         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32476         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
32477         return ret_val;
32478 }
32479
32480 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
32481         LDKChannelInfo orig_conv;
32482         orig_conv.inner = (void*)(orig & (~1));
32483         orig_conv.is_owned = false;
32484         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32485         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
32486         uint64_t ret_ref = 0;
32487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32490         ret_ref = (uint64_t)ret_var.inner;
32491         if (ret_var.is_owned) {
32492                 ret_ref |= 1;
32493         }
32494         return ret_ref;
32495 }
32496
32497 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
32498         LDKChannelInfo obj_conv;
32499         obj_conv.inner = (void*)(obj & (~1));
32500         obj_conv.is_owned = false;
32501         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32502         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
32503         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
32504         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32505         CVec_u8Z_free(ret_var);
32506         return ret_arr;
32507 }
32508
32509 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
32510         LDKu8slice ser_ref;
32511         ser_ref.datalen = ser->arr_len;
32512         ser_ref.data = ser->elems;
32513         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
32514         *ret_conv = ChannelInfo_read(ser_ref);
32515         return (uint64_t)ret_conv;
32516 }
32517
32518 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
32519         LDKRoutingFees this_obj_conv;
32520         this_obj_conv.inner = (void*)(this_obj & (~1));
32521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32523         RoutingFees_free(this_obj_conv);
32524 }
32525
32526 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
32527         LDKRoutingFees this_ptr_conv;
32528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32529         this_ptr_conv.is_owned = false;
32530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32531         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
32532         return ret_val;
32533 }
32534
32535 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
32536         LDKRoutingFees this_ptr_conv;
32537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32538         this_ptr_conv.is_owned = false;
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32540         RoutingFees_set_base_msat(&this_ptr_conv, val);
32541 }
32542
32543 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
32544         LDKRoutingFees this_ptr_conv;
32545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32546         this_ptr_conv.is_owned = false;
32547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32548         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
32549         return ret_val;
32550 }
32551
32552 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
32553         LDKRoutingFees this_ptr_conv;
32554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32555         this_ptr_conv.is_owned = false;
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32557         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
32558 }
32559
32560 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
32561         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
32562         uint64_t ret_ref = 0;
32563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32566         ret_ref = (uint64_t)ret_var.inner;
32567         if (ret_var.is_owned) {
32568                 ret_ref |= 1;
32569         }
32570         return ret_ref;
32571 }
32572
32573 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
32574         LDKRoutingFees a_conv;
32575         a_conv.inner = (void*)(a & (~1));
32576         a_conv.is_owned = false;
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32578         LDKRoutingFees b_conv;
32579         b_conv.inner = (void*)(b & (~1));
32580         b_conv.is_owned = false;
32581         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32582         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
32583         return ret_val;
32584 }
32585
32586 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
32587         LDKRoutingFees ret_var = RoutingFees_clone(arg);
32588 uint64_t ret_ref = 0;
32589 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32590 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32591 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32592 ret_ref = (uint64_t)ret_var.inner;
32593 if (ret_var.is_owned) {
32594         ret_ref |= 1;
32595 }
32596         return ret_ref;
32597 }
32598 int64_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
32599         LDKRoutingFees arg_conv;
32600         arg_conv.inner = (void*)(arg & (~1));
32601         arg_conv.is_owned = false;
32602         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32603         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
32604         return ret_val;
32605 }
32606
32607 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
32608         LDKRoutingFees orig_conv;
32609         orig_conv.inner = (void*)(orig & (~1));
32610         orig_conv.is_owned = false;
32611         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32612         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
32613         uint64_t ret_ref = 0;
32614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32617         ret_ref = (uint64_t)ret_var.inner;
32618         if (ret_var.is_owned) {
32619                 ret_ref |= 1;
32620         }
32621         return ret_ref;
32622 }
32623
32624 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
32625         LDKRoutingFees o_conv;
32626         o_conv.inner = (void*)(o & (~1));
32627         o_conv.is_owned = false;
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32629         int64_t ret_val = RoutingFees_hash(&o_conv);
32630         return ret_val;
32631 }
32632
32633 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
32634         LDKRoutingFees obj_conv;
32635         obj_conv.inner = (void*)(obj & (~1));
32636         obj_conv.is_owned = false;
32637         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32638         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
32639         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
32640         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32641         CVec_u8Z_free(ret_var);
32642         return ret_arr;
32643 }
32644
32645 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
32646         LDKu8slice ser_ref;
32647         ser_ref.datalen = ser->arr_len;
32648         ser_ref.data = ser->elems;
32649         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
32650         *ret_conv = RoutingFees_read(ser_ref);
32651         return (uint64_t)ret_conv;
32652 }
32653
32654 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
32655         LDKNodeAnnouncementInfo this_obj_conv;
32656         this_obj_conv.inner = (void*)(this_obj & (~1));
32657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32659         NodeAnnouncementInfo_free(this_obj_conv);
32660 }
32661
32662 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
32663         LDKNodeAnnouncementInfo this_ptr_conv;
32664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32665         this_ptr_conv.is_owned = false;
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32667         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
32668         uint64_t ret_ref = 0;
32669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32672         ret_ref = (uint64_t)ret_var.inner;
32673         if (ret_var.is_owned) {
32674                 ret_ref |= 1;
32675         }
32676         return ret_ref;
32677 }
32678
32679 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
32680         LDKNodeAnnouncementInfo this_ptr_conv;
32681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32682         this_ptr_conv.is_owned = false;
32683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32684         LDKNodeFeatures val_conv;
32685         val_conv.inner = (void*)(val & (~1));
32686         val_conv.is_owned = (val & 1) || (val == 0);
32687         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32688         val_conv = NodeFeatures_clone(&val_conv);
32689         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
32690 }
32691
32692 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
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         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
32698         return ret_val;
32699 }
32700
32701 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32702         LDKNodeAnnouncementInfo this_ptr_conv;
32703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32704         this_ptr_conv.is_owned = false;
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32706         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
32707 }
32708
32709 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
32710         LDKNodeAnnouncementInfo this_ptr_conv;
32711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32712         this_ptr_conv.is_owned = false;
32713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32714         int8_tArray ret_arr = init_int8_tArray(3);
32715         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
32716         return ret_arr;
32717 }
32718
32719 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
32720         LDKNodeAnnouncementInfo this_ptr_conv;
32721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32722         this_ptr_conv.is_owned = false;
32723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32724         LDKThreeBytes val_ref;
32725         CHECK(val->arr_len == 3);
32726         memcpy(val_ref.data, val->elems, 3);
32727         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
32728 }
32729
32730 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
32731         LDKNodeAnnouncementInfo this_ptr_conv;
32732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32733         this_ptr_conv.is_owned = false;
32734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32735         int8_tArray ret_arr = init_int8_tArray(32);
32736         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
32737         return ret_arr;
32738 }
32739
32740 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
32741         LDKNodeAnnouncementInfo this_ptr_conv;
32742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32743         this_ptr_conv.is_owned = false;
32744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32745         LDKThirtyTwoBytes val_ref;
32746         CHECK(val->arr_len == 32);
32747         memcpy(val_ref.data, val->elems, 32);
32748         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
32749 }
32750
32751 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
32752         LDKNodeAnnouncementInfo this_ptr_conv;
32753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32754         this_ptr_conv.is_owned = false;
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32756         LDKCVec_NetAddressZ val_constr;
32757         val_constr.datalen = val->arr_len;
32758         if (val_constr.datalen > 0)
32759                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32760         else
32761                 val_constr.data = NULL;
32762         uint32_t* val_vals = val->elems;
32763         for (size_t m = 0; m < val_constr.datalen; m++) {
32764                 uint32_t val_conv_12 = val_vals[m];
32765                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
32766                 CHECK_ACCESS(val_conv_12_ptr);
32767                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32768                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
32769                 val_constr.data[m] = val_conv_12_conv;
32770         }
32771         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
32772 }
32773
32774 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
32775         LDKNodeAnnouncementInfo this_ptr_conv;
32776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32777         this_ptr_conv.is_owned = false;
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32779         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
32780         uint64_t ret_ref = 0;
32781         if ((uint64_t)ret_var.inner > 4096) {
32782                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32783                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32785                 ret_ref = (uint64_t)ret_var.inner;
32786                 if (ret_var.is_owned) {
32787                         ret_ref |= 1;
32788                 }
32789         }
32790         return ret_ref;
32791 }
32792
32793 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32794         LDKNodeAnnouncementInfo this_ptr_conv;
32795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32796         this_ptr_conv.is_owned = false;
32797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32798         LDKNodeAnnouncement val_conv;
32799         val_conv.inner = (void*)(val & (~1));
32800         val_conv.is_owned = (val & 1) || (val == 0);
32801         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32802         val_conv = NodeAnnouncement_clone(&val_conv);
32803         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
32804 }
32805
32806 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) {
32807         LDKNodeFeatures features_arg_conv;
32808         features_arg_conv.inner = (void*)(features_arg & (~1));
32809         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
32810         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32811         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
32812         LDKThreeBytes rgb_arg_ref;
32813         CHECK(rgb_arg->arr_len == 3);
32814         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3);
32815         LDKThirtyTwoBytes alias_arg_ref;
32816         CHECK(alias_arg->arr_len == 32);
32817         memcpy(alias_arg_ref.data, alias_arg->elems, 32);
32818         LDKCVec_NetAddressZ addresses_arg_constr;
32819         addresses_arg_constr.datalen = addresses_arg->arr_len;
32820         if (addresses_arg_constr.datalen > 0)
32821                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32822         else
32823                 addresses_arg_constr.data = NULL;
32824         uint32_t* addresses_arg_vals = addresses_arg->elems;
32825         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
32826                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
32827                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
32828                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
32829                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
32830                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
32831         }
32832         LDKNodeAnnouncement announcement_message_arg_conv;
32833         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
32834         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
32835         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
32836         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
32837         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
32838         uint64_t ret_ref = 0;
32839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32842         ret_ref = (uint64_t)ret_var.inner;
32843         if (ret_var.is_owned) {
32844                 ret_ref |= 1;
32845         }
32846         return ret_ref;
32847 }
32848
32849 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
32850         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
32851 uint64_t ret_ref = 0;
32852 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32853 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
32856 if (ret_var.is_owned) {
32857         ret_ref |= 1;
32858 }
32859         return ret_ref;
32860 }
32861 int64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
32862         LDKNodeAnnouncementInfo arg_conv;
32863         arg_conv.inner = (void*)(arg & (~1));
32864         arg_conv.is_owned = false;
32865         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32866         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
32867         return ret_val;
32868 }
32869
32870 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
32871         LDKNodeAnnouncementInfo orig_conv;
32872         orig_conv.inner = (void*)(orig & (~1));
32873         orig_conv.is_owned = false;
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32875         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
32876         uint64_t ret_ref = 0;
32877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32880         ret_ref = (uint64_t)ret_var.inner;
32881         if (ret_var.is_owned) {
32882                 ret_ref |= 1;
32883         }
32884         return ret_ref;
32885 }
32886
32887 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
32888         LDKNodeAnnouncementInfo obj_conv;
32889         obj_conv.inner = (void*)(obj & (~1));
32890         obj_conv.is_owned = false;
32891         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32892         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
32893         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
32894         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32895         CVec_u8Z_free(ret_var);
32896         return ret_arr;
32897 }
32898
32899 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
32900         LDKu8slice ser_ref;
32901         ser_ref.datalen = ser->arr_len;
32902         ser_ref.data = ser->elems;
32903         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
32904         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
32905         return (uint64_t)ret_conv;
32906 }
32907
32908 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
32909         LDKNodeInfo this_obj_conv;
32910         this_obj_conv.inner = (void*)(this_obj & (~1));
32911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32913         NodeInfo_free(this_obj_conv);
32914 }
32915
32916 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
32917         LDKNodeInfo this_ptr_conv;
32918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32919         this_ptr_conv.is_owned = false;
32920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32921         LDKCVec_u64Z val_constr;
32922         val_constr.datalen = val->arr_len;
32923         if (val_constr.datalen > 0)
32924                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32925         else
32926                 val_constr.data = NULL;
32927         int64_t* val_vals = val->elems;
32928         for (size_t i = 0; i < val_constr.datalen; i++) {
32929                 int64_t val_conv_8 = val_vals[i];
32930                 val_constr.data[i] = val_conv_8;
32931         }
32932         NodeInfo_set_channels(&this_ptr_conv, val_constr);
32933 }
32934
32935 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
32936         LDKNodeInfo this_ptr_conv;
32937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32938         this_ptr_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32940         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
32941         uint64_t ret_ref = 0;
32942         if ((uint64_t)ret_var.inner > 4096) {
32943                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32944                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32946                 ret_ref = (uint64_t)ret_var.inner;
32947                 if (ret_var.is_owned) {
32948                         ret_ref |= 1;
32949                 }
32950         }
32951         return ret_ref;
32952 }
32953
32954 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) {
32955         LDKNodeInfo this_ptr_conv;
32956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32957         this_ptr_conv.is_owned = false;
32958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32959         LDKRoutingFees val_conv;
32960         val_conv.inner = (void*)(val & (~1));
32961         val_conv.is_owned = (val & 1) || (val == 0);
32962         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32963         val_conv = RoutingFees_clone(&val_conv);
32964         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
32965 }
32966
32967 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
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         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
32973         uint64_t ret_ref = 0;
32974         if ((uint64_t)ret_var.inner > 4096) {
32975                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32976                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32978                 ret_ref = (uint64_t)ret_var.inner;
32979                 if (ret_var.is_owned) {
32980                         ret_ref |= 1;
32981                 }
32982         }
32983         return ret_ref;
32984 }
32985
32986 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
32987         LDKNodeInfo this_ptr_conv;
32988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32989         this_ptr_conv.is_owned = false;
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32991         LDKNodeAnnouncementInfo val_conv;
32992         val_conv.inner = (void*)(val & (~1));
32993         val_conv.is_owned = (val & 1) || (val == 0);
32994         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32995         val_conv = NodeAnnouncementInfo_clone(&val_conv);
32996         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
32997 }
32998
32999 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) {
33000         LDKCVec_u64Z channels_arg_constr;
33001         channels_arg_constr.datalen = channels_arg->arr_len;
33002         if (channels_arg_constr.datalen > 0)
33003                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33004         else
33005                 channels_arg_constr.data = NULL;
33006         int64_t* channels_arg_vals = channels_arg->elems;
33007         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
33008                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
33009                 channels_arg_constr.data[i] = channels_arg_conv_8;
33010         }
33011         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
33012         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
33013         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
33014         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
33015         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
33016         LDKNodeAnnouncementInfo announcement_info_arg_conv;
33017         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
33018         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
33019         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
33020         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
33021         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
33022         uint64_t ret_ref = 0;
33023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33026         ret_ref = (uint64_t)ret_var.inner;
33027         if (ret_var.is_owned) {
33028                 ret_ref |= 1;
33029         }
33030         return ret_ref;
33031 }
33032
33033 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
33034         LDKNodeInfo ret_var = NodeInfo_clone(arg);
33035 uint64_t ret_ref = 0;
33036 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33037 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
33040 if (ret_var.is_owned) {
33041         ret_ref |= 1;
33042 }
33043         return ret_ref;
33044 }
33045 int64_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
33046         LDKNodeInfo arg_conv;
33047         arg_conv.inner = (void*)(arg & (~1));
33048         arg_conv.is_owned = false;
33049         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33050         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
33051         return ret_val;
33052 }
33053
33054 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
33055         LDKNodeInfo orig_conv;
33056         orig_conv.inner = (void*)(orig & (~1));
33057         orig_conv.is_owned = false;
33058         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33059         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
33060         uint64_t ret_ref = 0;
33061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33064         ret_ref = (uint64_t)ret_var.inner;
33065         if (ret_var.is_owned) {
33066                 ret_ref |= 1;
33067         }
33068         return ret_ref;
33069 }
33070
33071 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
33072         LDKNodeInfo obj_conv;
33073         obj_conv.inner = (void*)(obj & (~1));
33074         obj_conv.is_owned = false;
33075         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33076         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
33077         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
33078         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33079         CVec_u8Z_free(ret_var);
33080         return ret_arr;
33081 }
33082
33083 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
33084         LDKu8slice ser_ref;
33085         ser_ref.datalen = ser->arr_len;
33086         ser_ref.data = ser->elems;
33087         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
33088         *ret_conv = NodeInfo_read(ser_ref);
33089         return (uint64_t)ret_conv;
33090 }
33091
33092 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
33093         LDKNetworkGraph obj_conv;
33094         obj_conv.inner = (void*)(obj & (~1));
33095         obj_conv.is_owned = false;
33096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33097         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
33098         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
33099         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33100         CVec_u8Z_free(ret_var);
33101         return ret_arr;
33102 }
33103
33104 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
33105         LDKu8slice ser_ref;
33106         ser_ref.datalen = ser->arr_len;
33107         ser_ref.data = ser->elems;
33108         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
33109         *ret_conv = NetworkGraph_read(ser_ref);
33110         return (uint64_t)ret_conv;
33111 }
33112
33113 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
33114         LDKThirtyTwoBytes genesis_hash_ref;
33115         CHECK(genesis_hash->arr_len == 32);
33116         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32);
33117         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
33118         uint64_t ret_ref = 0;
33119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33122         ret_ref = (uint64_t)ret_var.inner;
33123         if (ret_var.is_owned) {
33124                 ret_ref |= 1;
33125         }
33126         return ret_ref;
33127 }
33128
33129 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
33130         LDKNetworkGraph this_arg_conv;
33131         this_arg_conv.inner = (void*)(this_arg & (~1));
33132         this_arg_conv.is_owned = false;
33133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33134         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
33135         uint64_t ret_ref = 0;
33136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33139         ret_ref = (uint64_t)ret_var.inner;
33140         if (ret_var.is_owned) {
33141                 ret_ref |= 1;
33142         }
33143         return ret_ref;
33144 }
33145
33146 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
33147         LDKNetworkGraph this_arg_conv;
33148         this_arg_conv.inner = (void*)(this_arg & (~1));
33149         this_arg_conv.is_owned = false;
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33151         LDKNodeAnnouncement msg_conv;
33152         msg_conv.inner = (void*)(msg & (~1));
33153         msg_conv.is_owned = false;
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33155         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33156         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
33157         return (uint64_t)ret_conv;
33158 }
33159
33160 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) {
33161         LDKNetworkGraph this_arg_conv;
33162         this_arg_conv.inner = (void*)(this_arg & (~1));
33163         this_arg_conv.is_owned = false;
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33165         LDKUnsignedNodeAnnouncement msg_conv;
33166         msg_conv.inner = (void*)(msg & (~1));
33167         msg_conv.is_owned = false;
33168         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33169         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33170         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
33171         return (uint64_t)ret_conv;
33172 }
33173
33174 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) {
33175         LDKNetworkGraph this_arg_conv;
33176         this_arg_conv.inner = (void*)(this_arg & (~1));
33177         this_arg_conv.is_owned = false;
33178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33179         LDKChannelAnnouncement msg_conv;
33180         msg_conv.inner = (void*)(msg & (~1));
33181         msg_conv.is_owned = false;
33182         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33183         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
33184         CHECK_ACCESS(chain_access_ptr);
33185         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33186         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33187         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33188                 // Manually implement clone for Java trait instances
33189         }
33190         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33191         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33192         return (uint64_t)ret_conv;
33193 }
33194
33195 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) {
33196         LDKNetworkGraph this_arg_conv;
33197         this_arg_conv.inner = (void*)(this_arg & (~1));
33198         this_arg_conv.is_owned = false;
33199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33200         LDKUnsignedChannelAnnouncement msg_conv;
33201         msg_conv.inner = (void*)(msg & (~1));
33202         msg_conv.is_owned = false;
33203         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33204         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
33205         CHECK_ACCESS(chain_access_ptr);
33206         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33207         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33208         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33209                 // Manually implement clone for Java trait instances
33210         }
33211         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33212         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33213         return (uint64_t)ret_conv;
33214 }
33215
33216 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) {
33217         LDKNetworkGraph this_arg_conv;
33218         this_arg_conv.inner = (void*)(this_arg & (~1));
33219         this_arg_conv.is_owned = false;
33220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33221         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
33222 }
33223
33224 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
33225         LDKNetworkGraph this_arg_conv;
33226         this_arg_conv.inner = (void*)(this_arg & (~1));
33227         this_arg_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33229         LDKPublicKey _node_id_ref;
33230         CHECK(_node_id->arr_len == 33);
33231         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33);
33232         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
33233 }
33234
33235 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) {
33236         LDKNetworkGraph this_arg_conv;
33237         this_arg_conv.inner = (void*)(this_arg & (~1));
33238         this_arg_conv.is_owned = false;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33240         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
33241 }
33242
33243 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
33244         LDKNetworkGraph this_arg_conv;
33245         this_arg_conv.inner = (void*)(this_arg & (~1));
33246         this_arg_conv.is_owned = false;
33247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33248         LDKChannelUpdate msg_conv;
33249         msg_conv.inner = (void*)(msg & (~1));
33250         msg_conv.is_owned = false;
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33252         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33253         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
33254         return (uint64_t)ret_conv;
33255 }
33256
33257 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
33258         LDKNetworkGraph this_arg_conv;
33259         this_arg_conv.inner = (void*)(this_arg & (~1));
33260         this_arg_conv.is_owned = false;
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33262         LDKUnsignedChannelUpdate msg_conv;
33263         msg_conv.inner = (void*)(msg & (~1));
33264         msg_conv.is_owned = false;
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33266         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33267         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
33268         return (uint64_t)ret_conv;
33269 }
33270
33271 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
33272         LDKReadOnlyNetworkGraph this_arg_conv;
33273         this_arg_conv.inner = (void*)(this_arg & (~1));
33274         this_arg_conv.is_owned = false;
33275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33276         LDKPublicKey pubkey_ref;
33277         CHECK(pubkey->arr_len == 33);
33278         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33);
33279         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
33280         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
33281         uint64_t ret_ref = (uint64_t)ret_copy;
33282         return ret_ref;
33283 }
33284
33285 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
33286         LDKRouteHop this_obj_conv;
33287         this_obj_conv.inner = (void*)(this_obj & (~1));
33288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33290         RouteHop_free(this_obj_conv);
33291 }
33292
33293 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
33294         LDKRouteHop this_ptr_conv;
33295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33296         this_ptr_conv.is_owned = false;
33297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33298         int8_tArray ret_arr = init_int8_tArray(33);
33299         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
33300         return ret_arr;
33301 }
33302
33303 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33304         LDKRouteHop this_ptr_conv;
33305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33306         this_ptr_conv.is_owned = false;
33307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33308         LDKPublicKey val_ref;
33309         CHECK(val->arr_len == 33);
33310         memcpy(val_ref.compressed_form, val->elems, 33);
33311         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
33312 }
33313
33314 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
33315         LDKRouteHop this_ptr_conv;
33316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33317         this_ptr_conv.is_owned = false;
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33319         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
33320         uint64_t ret_ref = 0;
33321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33324         ret_ref = (uint64_t)ret_var.inner;
33325         if (ret_var.is_owned) {
33326                 ret_ref |= 1;
33327         }
33328         return ret_ref;
33329 }
33330
33331 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
33332         LDKRouteHop this_ptr_conv;
33333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33334         this_ptr_conv.is_owned = false;
33335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33336         LDKNodeFeatures val_conv;
33337         val_conv.inner = (void*)(val & (~1));
33338         val_conv.is_owned = (val & 1) || (val == 0);
33339         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33340         val_conv = NodeFeatures_clone(&val_conv);
33341         RouteHop_set_node_features(&this_ptr_conv, val_conv);
33342 }
33343
33344 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
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         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
33350         return ret_val;
33351 }
33352
33353 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
33354         LDKRouteHop this_ptr_conv;
33355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33356         this_ptr_conv.is_owned = false;
33357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33358         RouteHop_set_short_channel_id(&this_ptr_conv, val);
33359 }
33360
33361 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
33362         LDKRouteHop this_ptr_conv;
33363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33364         this_ptr_conv.is_owned = false;
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33366         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
33367         uint64_t ret_ref = 0;
33368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33371         ret_ref = (uint64_t)ret_var.inner;
33372         if (ret_var.is_owned) {
33373                 ret_ref |= 1;
33374         }
33375         return ret_ref;
33376 }
33377
33378 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
33379         LDKRouteHop this_ptr_conv;
33380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33381         this_ptr_conv.is_owned = false;
33382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33383         LDKChannelFeatures val_conv;
33384         val_conv.inner = (void*)(val & (~1));
33385         val_conv.is_owned = (val & 1) || (val == 0);
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33387         val_conv = ChannelFeatures_clone(&val_conv);
33388         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
33389 }
33390
33391 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
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         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
33397         return ret_val;
33398 }
33399
33400 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
33401         LDKRouteHop this_ptr_conv;
33402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33403         this_ptr_conv.is_owned = false;
33404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33405         RouteHop_set_fee_msat(&this_ptr_conv, val);
33406 }
33407
33408 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
33409         LDKRouteHop this_ptr_conv;
33410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33411         this_ptr_conv.is_owned = false;
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33413         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
33414         return ret_val;
33415 }
33416
33417 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33418         LDKRouteHop this_ptr_conv;
33419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33420         this_ptr_conv.is_owned = false;
33421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33422         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
33423 }
33424
33425 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) {
33426         LDKPublicKey pubkey_arg_ref;
33427         CHECK(pubkey_arg->arr_len == 33);
33428         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33);
33429         LDKNodeFeatures node_features_arg_conv;
33430         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
33431         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
33432         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
33433         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
33434         LDKChannelFeatures channel_features_arg_conv;
33435         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
33436         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
33438         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
33439         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);
33440         uint64_t ret_ref = 0;
33441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33444         ret_ref = (uint64_t)ret_var.inner;
33445         if (ret_var.is_owned) {
33446                 ret_ref |= 1;
33447         }
33448         return ret_ref;
33449 }
33450
33451 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
33452         LDKRouteHop ret_var = RouteHop_clone(arg);
33453 uint64_t ret_ref = 0;
33454 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33455 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
33458 if (ret_var.is_owned) {
33459         ret_ref |= 1;
33460 }
33461         return ret_ref;
33462 }
33463 int64_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
33464         LDKRouteHop arg_conv;
33465         arg_conv.inner = (void*)(arg & (~1));
33466         arg_conv.is_owned = false;
33467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33468         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
33469         return ret_val;
33470 }
33471
33472 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
33473         LDKRouteHop orig_conv;
33474         orig_conv.inner = (void*)(orig & (~1));
33475         orig_conv.is_owned = false;
33476         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33477         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
33478         uint64_t ret_ref = 0;
33479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33482         ret_ref = (uint64_t)ret_var.inner;
33483         if (ret_var.is_owned) {
33484                 ret_ref |= 1;
33485         }
33486         return ret_ref;
33487 }
33488
33489 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
33490         LDKRouteHop o_conv;
33491         o_conv.inner = (void*)(o & (~1));
33492         o_conv.is_owned = false;
33493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33494         int64_t ret_val = RouteHop_hash(&o_conv);
33495         return ret_val;
33496 }
33497
33498 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
33499         LDKRouteHop a_conv;
33500         a_conv.inner = (void*)(a & (~1));
33501         a_conv.is_owned = false;
33502         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33503         LDKRouteHop b_conv;
33504         b_conv.inner = (void*)(b & (~1));
33505         b_conv.is_owned = false;
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33507         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
33508         return ret_val;
33509 }
33510
33511 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
33512         LDKRouteHop obj_conv;
33513         obj_conv.inner = (void*)(obj & (~1));
33514         obj_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33516         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
33517         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
33518         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33519         CVec_u8Z_free(ret_var);
33520         return ret_arr;
33521 }
33522
33523 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
33524         LDKu8slice ser_ref;
33525         ser_ref.datalen = ser->arr_len;
33526         ser_ref.data = ser->elems;
33527         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
33528         *ret_conv = RouteHop_read(ser_ref);
33529         return (uint64_t)ret_conv;
33530 }
33531
33532 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
33533         LDKRoute this_obj_conv;
33534         this_obj_conv.inner = (void*)(this_obj & (~1));
33535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33537         Route_free(this_obj_conv);
33538 }
33539
33540 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
33541         LDKRoute this_ptr_conv;
33542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33543         this_ptr_conv.is_owned = false;
33544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33545         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
33546         ptrArray ret_arr = NULL;
33547         ret_arr = init_ptrArray(ret_var.datalen);
33548         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
33549         for (size_t m = 0; m < ret_var.datalen; m++) {
33550                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
33551                 uint32_tArray ret_conv_12_arr = NULL;
33552                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen);
33553                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
33554                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
33555                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
33556                         uint64_t ret_conv_12_conv_10_ref = 0;
33557                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33558                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33559                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
33560                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
33561                         if (ret_conv_12_conv_10_var.is_owned) {
33562                                 ret_conv_12_conv_10_ref |= 1;
33563                         }
33564                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
33565                 }
33566                 
33567                 FREE(ret_conv_12_var.data);
33568                 ret_arr_ptr[m] = ret_conv_12_arr;
33569         }
33570         
33571         FREE(ret_var.data);
33572         return ret_arr;
33573 }
33574
33575 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
33576         LDKRoute this_ptr_conv;
33577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33578         this_ptr_conv.is_owned = false;
33579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33580         LDKCVec_CVec_RouteHopZZ val_constr;
33581         val_constr.datalen = val->arr_len;
33582         if (val_constr.datalen > 0)
33583                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33584         else
33585                 val_constr.data = NULL;
33586         uint32_tArray* val_vals = (void*) val->elems;
33587         for (size_t m = 0; m < val_constr.datalen; m++) {
33588                 uint32_tArray val_conv_12 = val_vals[m];
33589                 LDKCVec_RouteHopZ val_conv_12_constr;
33590                 val_conv_12_constr.datalen = val_conv_12->arr_len;
33591                 if (val_conv_12_constr.datalen > 0)
33592                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33593                 else
33594                         val_conv_12_constr.data = NULL;
33595                 uint32_t* val_conv_12_vals = val_conv_12->elems;
33596                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
33597                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
33598                         LDKRouteHop val_conv_12_conv_10_conv;
33599                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
33600                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
33601                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
33602                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
33603                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
33604                 }
33605                 val_constr.data[m] = val_conv_12_constr;
33606         }
33607         Route_set_paths(&this_ptr_conv, val_constr);
33608 }
33609
33610 uint32_t  __attribute__((export_name("TS_Route_get_payee"))) TS_Route_get_payee(uint32_t this_ptr) {
33611         LDKRoute this_ptr_conv;
33612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33613         this_ptr_conv.is_owned = false;
33614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33615         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
33616         uint64_t ret_ref = 0;
33617         if ((uint64_t)ret_var.inner > 4096) {
33618                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33619                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33621                 ret_ref = (uint64_t)ret_var.inner;
33622                 if (ret_var.is_owned) {
33623                         ret_ref |= 1;
33624                 }
33625         }
33626         return ret_ref;
33627 }
33628
33629 void  __attribute__((export_name("TS_Route_set_payee"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
33630         LDKRoute this_ptr_conv;
33631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33632         this_ptr_conv.is_owned = false;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33634         LDKPayee val_conv;
33635         val_conv.inner = (void*)(val & (~1));
33636         val_conv.is_owned = (val & 1) || (val == 0);
33637         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33638         val_conv = Payee_clone(&val_conv);
33639         Route_set_payee(&this_ptr_conv, val_conv);
33640 }
33641
33642 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
33643         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
33644         paths_arg_constr.datalen = paths_arg->arr_len;
33645         if (paths_arg_constr.datalen > 0)
33646                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33647         else
33648                 paths_arg_constr.data = NULL;
33649         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
33650         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
33651                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
33652                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
33653                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
33654                 if (paths_arg_conv_12_constr.datalen > 0)
33655                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33656                 else
33657                         paths_arg_conv_12_constr.data = NULL;
33658                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
33659                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
33660                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
33661                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
33662                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
33663                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
33664                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
33665                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
33666                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
33667                 }
33668                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
33669         }
33670         LDKPayee payee_arg_conv;
33671         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33672         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33673         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33674         payee_arg_conv = Payee_clone(&payee_arg_conv);
33675         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
33676         uint64_t ret_ref = 0;
33677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33680         ret_ref = (uint64_t)ret_var.inner;
33681         if (ret_var.is_owned) {
33682                 ret_ref |= 1;
33683         }
33684         return ret_ref;
33685 }
33686
33687 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
33688         LDKRoute ret_var = Route_clone(arg);
33689 uint64_t ret_ref = 0;
33690 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33691 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
33694 if (ret_var.is_owned) {
33695         ret_ref |= 1;
33696 }
33697         return ret_ref;
33698 }
33699 int64_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
33700         LDKRoute arg_conv;
33701         arg_conv.inner = (void*)(arg & (~1));
33702         arg_conv.is_owned = false;
33703         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33704         int64_t ret_val = Route_clone_ptr(&arg_conv);
33705         return ret_val;
33706 }
33707
33708 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
33709         LDKRoute orig_conv;
33710         orig_conv.inner = (void*)(orig & (~1));
33711         orig_conv.is_owned = false;
33712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33713         LDKRoute ret_var = Route_clone(&orig_conv);
33714         uint64_t ret_ref = 0;
33715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33718         ret_ref = (uint64_t)ret_var.inner;
33719         if (ret_var.is_owned) {
33720                 ret_ref |= 1;
33721         }
33722         return ret_ref;
33723 }
33724
33725 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
33726         LDKRoute o_conv;
33727         o_conv.inner = (void*)(o & (~1));
33728         o_conv.is_owned = false;
33729         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33730         int64_t ret_val = Route_hash(&o_conv);
33731         return ret_val;
33732 }
33733
33734 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
33735         LDKRoute a_conv;
33736         a_conv.inner = (void*)(a & (~1));
33737         a_conv.is_owned = false;
33738         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33739         LDKRoute b_conv;
33740         b_conv.inner = (void*)(b & (~1));
33741         b_conv.is_owned = false;
33742         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33743         jboolean ret_val = Route_eq(&a_conv, &b_conv);
33744         return ret_val;
33745 }
33746
33747 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
33748         LDKRoute this_arg_conv;
33749         this_arg_conv.inner = (void*)(this_arg & (~1));
33750         this_arg_conv.is_owned = false;
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33752         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
33753         return ret_val;
33754 }
33755
33756 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
33757         LDKRoute this_arg_conv;
33758         this_arg_conv.inner = (void*)(this_arg & (~1));
33759         this_arg_conv.is_owned = false;
33760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33761         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
33762         return ret_val;
33763 }
33764
33765 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
33766         LDKRoute obj_conv;
33767         obj_conv.inner = (void*)(obj & (~1));
33768         obj_conv.is_owned = false;
33769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33770         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
33771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
33772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33773         CVec_u8Z_free(ret_var);
33774         return ret_arr;
33775 }
33776
33777 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
33778         LDKu8slice ser_ref;
33779         ser_ref.datalen = ser->arr_len;
33780         ser_ref.data = ser->elems;
33781         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
33782         *ret_conv = Route_read(ser_ref);
33783         return (uint64_t)ret_conv;
33784 }
33785
33786 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
33787         LDKRouteParameters this_obj_conv;
33788         this_obj_conv.inner = (void*)(this_obj & (~1));
33789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33791         RouteParameters_free(this_obj_conv);
33792 }
33793
33794 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payee"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
33795         LDKRouteParameters this_ptr_conv;
33796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33797         this_ptr_conv.is_owned = false;
33798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33799         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
33800         uint64_t ret_ref = 0;
33801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33804         ret_ref = (uint64_t)ret_var.inner;
33805         if (ret_var.is_owned) {
33806                 ret_ref |= 1;
33807         }
33808         return ret_ref;
33809 }
33810
33811 void  __attribute__((export_name("TS_RouteParameters_set_payee"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
33812         LDKRouteParameters this_ptr_conv;
33813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33814         this_ptr_conv.is_owned = false;
33815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33816         LDKPayee val_conv;
33817         val_conv.inner = (void*)(val & (~1));
33818         val_conv.is_owned = (val & 1) || (val == 0);
33819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33820         val_conv = Payee_clone(&val_conv);
33821         RouteParameters_set_payee(&this_ptr_conv, val_conv);
33822 }
33823
33824 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
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         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
33830         return ret_val;
33831 }
33832
33833 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
33834         LDKRouteParameters this_ptr_conv;
33835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33836         this_ptr_conv.is_owned = false;
33837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33838         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
33839 }
33840
33841 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
33842         LDKRouteParameters this_ptr_conv;
33843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33844         this_ptr_conv.is_owned = false;
33845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33846         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
33847         return ret_val;
33848 }
33849
33850 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) {
33851         LDKRouteParameters this_ptr_conv;
33852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33853         this_ptr_conv.is_owned = false;
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33855         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
33856 }
33857
33858 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) {
33859         LDKPayee payee_arg_conv;
33860         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33861         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33862         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33863         payee_arg_conv = Payee_clone(&payee_arg_conv);
33864         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
33865         uint64_t ret_ref = 0;
33866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33869         ret_ref = (uint64_t)ret_var.inner;
33870         if (ret_var.is_owned) {
33871                 ret_ref |= 1;
33872         }
33873         return ret_ref;
33874 }
33875
33876 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
33877         LDKRouteParameters ret_var = RouteParameters_clone(arg);
33878 uint64_t ret_ref = 0;
33879 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33880 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
33883 if (ret_var.is_owned) {
33884         ret_ref |= 1;
33885 }
33886         return ret_ref;
33887 }
33888 int64_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
33889         LDKRouteParameters arg_conv;
33890         arg_conv.inner = (void*)(arg & (~1));
33891         arg_conv.is_owned = false;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33893         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
33894         return ret_val;
33895 }
33896
33897 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
33898         LDKRouteParameters orig_conv;
33899         orig_conv.inner = (void*)(orig & (~1));
33900         orig_conv.is_owned = false;
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33902         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
33903         uint64_t ret_ref = 0;
33904         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33905         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33907         ret_ref = (uint64_t)ret_var.inner;
33908         if (ret_var.is_owned) {
33909                 ret_ref |= 1;
33910         }
33911         return ret_ref;
33912 }
33913
33914 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
33915         LDKRouteParameters obj_conv;
33916         obj_conv.inner = (void*)(obj & (~1));
33917         obj_conv.is_owned = false;
33918         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33919         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
33920         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
33921         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33922         CVec_u8Z_free(ret_var);
33923         return ret_arr;
33924 }
33925
33926 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
33927         LDKu8slice ser_ref;
33928         ser_ref.datalen = ser->arr_len;
33929         ser_ref.data = ser->elems;
33930         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
33931         *ret_conv = RouteParameters_read(ser_ref);
33932         return (uint64_t)ret_conv;
33933 }
33934
33935 void  __attribute__((export_name("TS_Payee_free"))) TS_Payee_free(uint32_t this_obj) {
33936         LDKPayee this_obj_conv;
33937         this_obj_conv.inner = (void*)(this_obj & (~1));
33938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33940         Payee_free(this_obj_conv);
33941 }
33942
33943 int8_tArray  __attribute__((export_name("TS_Payee_get_pubkey"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
33944         LDKPayee this_ptr_conv;
33945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33946         this_ptr_conv.is_owned = false;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33948         int8_tArray ret_arr = init_int8_tArray(33);
33949         memcpy(ret_arr->elems, Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
33950         return ret_arr;
33951 }
33952
33953 void  __attribute__((export_name("TS_Payee_set_pubkey"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33954         LDKPayee this_ptr_conv;
33955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33956         this_ptr_conv.is_owned = false;
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33958         LDKPublicKey val_ref;
33959         CHECK(val->arr_len == 33);
33960         memcpy(val_ref.compressed_form, val->elems, 33);
33961         Payee_set_pubkey(&this_ptr_conv, val_ref);
33962 }
33963
33964 uint32_t  __attribute__((export_name("TS_Payee_get_features"))) TS_Payee_get_features(uint32_t this_ptr) {
33965         LDKPayee this_ptr_conv;
33966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33967         this_ptr_conv.is_owned = false;
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33969         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
33970         uint64_t ret_ref = 0;
33971         if ((uint64_t)ret_var.inner > 4096) {
33972                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33973                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33975                 ret_ref = (uint64_t)ret_var.inner;
33976                 if (ret_var.is_owned) {
33977                         ret_ref |= 1;
33978                 }
33979         }
33980         return ret_ref;
33981 }
33982
33983 void  __attribute__((export_name("TS_Payee_set_features"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
33984         LDKPayee this_ptr_conv;
33985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33986         this_ptr_conv.is_owned = false;
33987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33988         LDKInvoiceFeatures val_conv;
33989         val_conv.inner = (void*)(val & (~1));
33990         val_conv.is_owned = (val & 1) || (val == 0);
33991         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33992         val_conv = InvoiceFeatures_clone(&val_conv);
33993         Payee_set_features(&this_ptr_conv, val_conv);
33994 }
33995
33996 uint32_tArray  __attribute__((export_name("TS_Payee_get_route_hints"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
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         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
34002         uint32_tArray ret_arr = NULL;
34003         ret_arr = init_uint32_tArray(ret_var.datalen);
34004         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34005         for (size_t l = 0; l < ret_var.datalen; l++) {
34006                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
34007                 uint64_t ret_conv_11_ref = 0;
34008                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34009                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34010                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
34011                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
34012                 if (ret_conv_11_var.is_owned) {
34013                         ret_conv_11_ref |= 1;
34014                 }
34015                 ret_arr_ptr[l] = ret_conv_11_ref;
34016         }
34017         
34018         FREE(ret_var.data);
34019         return ret_arr;
34020 }
34021
34022 void  __attribute__((export_name("TS_Payee_set_route_hints"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
34023         LDKPayee this_ptr_conv;
34024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34025         this_ptr_conv.is_owned = false;
34026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34027         LDKCVec_RouteHintZ val_constr;
34028         val_constr.datalen = val->arr_len;
34029         if (val_constr.datalen > 0)
34030                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34031         else
34032                 val_constr.data = NULL;
34033         uint32_t* val_vals = val->elems;
34034         for (size_t l = 0; l < val_constr.datalen; l++) {
34035                 uint32_t val_conv_11 = val_vals[l];
34036                 LDKRouteHint val_conv_11_conv;
34037                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
34038                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
34039                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
34040                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
34041                 val_constr.data[l] = val_conv_11_conv;
34042         }
34043         Payee_set_route_hints(&this_ptr_conv, val_constr);
34044 }
34045
34046 uint32_t  __attribute__((export_name("TS_Payee_get_expiry_time"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
34047         LDKPayee this_ptr_conv;
34048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34049         this_ptr_conv.is_owned = false;
34050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34051         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34052         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
34053         uint64_t ret_ref = (uint64_t)ret_copy;
34054         return ret_ref;
34055 }
34056
34057 void  __attribute__((export_name("TS_Payee_set_expiry_time"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
34058         LDKPayee this_ptr_conv;
34059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34060         this_ptr_conv.is_owned = false;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34062         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34063         CHECK_ACCESS(val_ptr);
34064         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34065         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34066         Payee_set_expiry_time(&this_ptr_conv, val_conv);
34067 }
34068
34069 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) {
34070         LDKPublicKey pubkey_arg_ref;
34071         CHECK(pubkey_arg->arr_len == 33);
34072         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33);
34073         LDKInvoiceFeatures features_arg_conv;
34074         features_arg_conv.inner = (void*)(features_arg & (~1));
34075         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
34076         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34077         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
34078         LDKCVec_RouteHintZ route_hints_arg_constr;
34079         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
34080         if (route_hints_arg_constr.datalen > 0)
34081                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34082         else
34083                 route_hints_arg_constr.data = NULL;
34084         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
34085         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
34086                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
34087                 LDKRouteHint route_hints_arg_conv_11_conv;
34088                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
34089                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
34090                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
34091                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
34092                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
34093         }
34094         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
34095         CHECK_ACCESS(expiry_time_arg_ptr);
34096         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
34097         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
34098         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
34099         uint64_t ret_ref = 0;
34100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34103         ret_ref = (uint64_t)ret_var.inner;
34104         if (ret_var.is_owned) {
34105                 ret_ref |= 1;
34106         }
34107         return ret_ref;
34108 }
34109
34110 static inline uintptr_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
34111         LDKPayee ret_var = Payee_clone(arg);
34112 uint64_t ret_ref = 0;
34113 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
34117 if (ret_var.is_owned) {
34118         ret_ref |= 1;
34119 }
34120         return ret_ref;
34121 }
34122 int64_t  __attribute__((export_name("TS_Payee_clone_ptr"))) TS_Payee_clone_ptr(uint32_t arg) {
34123         LDKPayee arg_conv;
34124         arg_conv.inner = (void*)(arg & (~1));
34125         arg_conv.is_owned = false;
34126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34127         int64_t ret_val = Payee_clone_ptr(&arg_conv);
34128         return ret_val;
34129 }
34130
34131 uint32_t  __attribute__((export_name("TS_Payee_clone"))) TS_Payee_clone(uint32_t orig) {
34132         LDKPayee orig_conv;
34133         orig_conv.inner = (void*)(orig & (~1));
34134         orig_conv.is_owned = false;
34135         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34136         LDKPayee ret_var = Payee_clone(&orig_conv);
34137         uint64_t ret_ref = 0;
34138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34141         ret_ref = (uint64_t)ret_var.inner;
34142         if (ret_var.is_owned) {
34143                 ret_ref |= 1;
34144         }
34145         return ret_ref;
34146 }
34147
34148 int64_t  __attribute__((export_name("TS_Payee_hash"))) TS_Payee_hash(uint32_t o) {
34149         LDKPayee o_conv;
34150         o_conv.inner = (void*)(o & (~1));
34151         o_conv.is_owned = false;
34152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34153         int64_t ret_val = Payee_hash(&o_conv);
34154         return ret_val;
34155 }
34156
34157 jboolean  __attribute__((export_name("TS_Payee_eq"))) TS_Payee_eq(uint32_t a, uint32_t b) {
34158         LDKPayee a_conv;
34159         a_conv.inner = (void*)(a & (~1));
34160         a_conv.is_owned = false;
34161         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34162         LDKPayee b_conv;
34163         b_conv.inner = (void*)(b & (~1));
34164         b_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34166         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
34167         return ret_val;
34168 }
34169
34170 int8_tArray  __attribute__((export_name("TS_Payee_write"))) TS_Payee_write(uint32_t obj) {
34171         LDKPayee obj_conv;
34172         obj_conv.inner = (void*)(obj & (~1));
34173         obj_conv.is_owned = false;
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34175         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
34176         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
34177         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34178         CVec_u8Z_free(ret_var);
34179         return ret_arr;
34180 }
34181
34182 uint32_t  __attribute__((export_name("TS_Payee_read"))) TS_Payee_read(int8_tArray ser) {
34183         LDKu8slice ser_ref;
34184         ser_ref.datalen = ser->arr_len;
34185         ser_ref.data = ser->elems;
34186         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
34187         *ret_conv = Payee_read(ser_ref);
34188         return (uint64_t)ret_conv;
34189 }
34190
34191 uint32_t  __attribute__((export_name("TS_Payee_from_node_id"))) TS_Payee_from_node_id(int8_tArray pubkey) {
34192         LDKPublicKey pubkey_ref;
34193         CHECK(pubkey->arr_len == 33);
34194         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33);
34195         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
34196         uint64_t ret_ref = 0;
34197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34200         ret_ref = (uint64_t)ret_var.inner;
34201         if (ret_var.is_owned) {
34202                 ret_ref |= 1;
34203         }
34204         return ret_ref;
34205 }
34206
34207 uint32_t  __attribute__((export_name("TS_Payee_for_keysend"))) TS_Payee_for_keysend(int8_tArray pubkey) {
34208         LDKPublicKey pubkey_ref;
34209         CHECK(pubkey->arr_len == 33);
34210         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33);
34211         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
34212         uint64_t ret_ref = 0;
34213         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34214         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34216         ret_ref = (uint64_t)ret_var.inner;
34217         if (ret_var.is_owned) {
34218                 ret_ref |= 1;
34219         }
34220         return ret_ref;
34221 }
34222
34223 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
34224         LDKRouteHint this_obj_conv;
34225         this_obj_conv.inner = (void*)(this_obj & (~1));
34226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34228         RouteHint_free(this_obj_conv);
34229 }
34230
34231 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
34232         LDKRouteHint this_ptr_conv;
34233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34234         this_ptr_conv.is_owned = false;
34235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34236         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
34237         uint32_tArray ret_arr = NULL;
34238         ret_arr = init_uint32_tArray(ret_var.datalen);
34239         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34240         for (size_t o = 0; o < ret_var.datalen; o++) {
34241                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
34242                 uint64_t ret_conv_14_ref = 0;
34243                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34244                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34245                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
34246                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
34247                 if (ret_conv_14_var.is_owned) {
34248                         ret_conv_14_ref |= 1;
34249                 }
34250                 ret_arr_ptr[o] = ret_conv_14_ref;
34251         }
34252         
34253         FREE(ret_var.data);
34254         return ret_arr;
34255 }
34256
34257 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
34258         LDKRouteHint this_ptr_conv;
34259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34260         this_ptr_conv.is_owned = false;
34261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34262         LDKCVec_RouteHintHopZ val_constr;
34263         val_constr.datalen = val->arr_len;
34264         if (val_constr.datalen > 0)
34265                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34266         else
34267                 val_constr.data = NULL;
34268         uint32_t* val_vals = val->elems;
34269         for (size_t o = 0; o < val_constr.datalen; o++) {
34270                 uint32_t val_conv_14 = val_vals[o];
34271                 LDKRouteHintHop val_conv_14_conv;
34272                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
34273                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
34274                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
34275                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
34276                 val_constr.data[o] = val_conv_14_conv;
34277         }
34278         RouteHint_set_a(&this_ptr_conv, val_constr);
34279 }
34280
34281 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
34282         LDKCVec_RouteHintHopZ a_arg_constr;
34283         a_arg_constr.datalen = a_arg->arr_len;
34284         if (a_arg_constr.datalen > 0)
34285                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34286         else
34287                 a_arg_constr.data = NULL;
34288         uint32_t* a_arg_vals = a_arg->elems;
34289         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
34290                 uint32_t a_arg_conv_14 = a_arg_vals[o];
34291                 LDKRouteHintHop a_arg_conv_14_conv;
34292                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
34293                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
34294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
34295                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
34296                 a_arg_constr.data[o] = a_arg_conv_14_conv;
34297         }
34298         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
34299         uint64_t ret_ref = 0;
34300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34303         ret_ref = (uint64_t)ret_var.inner;
34304         if (ret_var.is_owned) {
34305                 ret_ref |= 1;
34306         }
34307         return ret_ref;
34308 }
34309
34310 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
34311         LDKRouteHint ret_var = RouteHint_clone(arg);
34312 uint64_t ret_ref = 0;
34313 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34314 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
34317 if (ret_var.is_owned) {
34318         ret_ref |= 1;
34319 }
34320         return ret_ref;
34321 }
34322 int64_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
34323         LDKRouteHint arg_conv;
34324         arg_conv.inner = (void*)(arg & (~1));
34325         arg_conv.is_owned = false;
34326         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34327         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
34328         return ret_val;
34329 }
34330
34331 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
34332         LDKRouteHint orig_conv;
34333         orig_conv.inner = (void*)(orig & (~1));
34334         orig_conv.is_owned = false;
34335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34336         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
34337         uint64_t ret_ref = 0;
34338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34341         ret_ref = (uint64_t)ret_var.inner;
34342         if (ret_var.is_owned) {
34343                 ret_ref |= 1;
34344         }
34345         return ret_ref;
34346 }
34347
34348 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
34349         LDKRouteHint o_conv;
34350         o_conv.inner = (void*)(o & (~1));
34351         o_conv.is_owned = false;
34352         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34353         int64_t ret_val = RouteHint_hash(&o_conv);
34354         return ret_val;
34355 }
34356
34357 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
34358         LDKRouteHint a_conv;
34359         a_conv.inner = (void*)(a & (~1));
34360         a_conv.is_owned = false;
34361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34362         LDKRouteHint b_conv;
34363         b_conv.inner = (void*)(b & (~1));
34364         b_conv.is_owned = false;
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34366         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
34367         return ret_val;
34368 }
34369
34370 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
34371         LDKRouteHint obj_conv;
34372         obj_conv.inner = (void*)(obj & (~1));
34373         obj_conv.is_owned = false;
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34375         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
34376         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
34377         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34378         CVec_u8Z_free(ret_var);
34379         return ret_arr;
34380 }
34381
34382 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
34383         LDKu8slice ser_ref;
34384         ser_ref.datalen = ser->arr_len;
34385         ser_ref.data = ser->elems;
34386         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
34387         *ret_conv = RouteHint_read(ser_ref);
34388         return (uint64_t)ret_conv;
34389 }
34390
34391 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
34392         LDKRouteHintHop this_obj_conv;
34393         this_obj_conv.inner = (void*)(this_obj & (~1));
34394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34396         RouteHintHop_free(this_obj_conv);
34397 }
34398
34399 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
34400         LDKRouteHintHop this_ptr_conv;
34401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34402         this_ptr_conv.is_owned = false;
34403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34404         int8_tArray ret_arr = init_int8_tArray(33);
34405         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
34406         return ret_arr;
34407 }
34408
34409 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
34410         LDKRouteHintHop this_ptr_conv;
34411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34412         this_ptr_conv.is_owned = false;
34413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34414         LDKPublicKey val_ref;
34415         CHECK(val->arr_len == 33);
34416         memcpy(val_ref.compressed_form, val->elems, 33);
34417         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
34418 }
34419
34420 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
34421         LDKRouteHintHop this_ptr_conv;
34422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34423         this_ptr_conv.is_owned = false;
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34425         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
34426         return ret_val;
34427 }
34428
34429 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
34430         LDKRouteHintHop this_ptr_conv;
34431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34432         this_ptr_conv.is_owned = false;
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34434         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
34435 }
34436
34437 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
34438         LDKRouteHintHop this_ptr_conv;
34439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34440         this_ptr_conv.is_owned = false;
34441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34442         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
34443         uint64_t ret_ref = 0;
34444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34447         ret_ref = (uint64_t)ret_var.inner;
34448         if (ret_var.is_owned) {
34449                 ret_ref |= 1;
34450         }
34451         return ret_ref;
34452 }
34453
34454 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
34455         LDKRouteHintHop this_ptr_conv;
34456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34457         this_ptr_conv.is_owned = false;
34458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34459         LDKRoutingFees val_conv;
34460         val_conv.inner = (void*)(val & (~1));
34461         val_conv.is_owned = (val & 1) || (val == 0);
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34463         val_conv = RoutingFees_clone(&val_conv);
34464         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
34465 }
34466
34467 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
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         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
34473         return ret_val;
34474 }
34475
34476 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
34477         LDKRouteHintHop this_ptr_conv;
34478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34479         this_ptr_conv.is_owned = false;
34480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34481         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
34482 }
34483
34484 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
34485         LDKRouteHintHop this_ptr_conv;
34486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34487         this_ptr_conv.is_owned = false;
34488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34489         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34490         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
34491         uint64_t ret_ref = (uint64_t)ret_copy;
34492         return ret_ref;
34493 }
34494
34495 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
34496         LDKRouteHintHop this_ptr_conv;
34497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34498         this_ptr_conv.is_owned = false;
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34500         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34501         CHECK_ACCESS(val_ptr);
34502         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34503         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34504         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
34505 }
34506
34507 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
34508         LDKRouteHintHop this_ptr_conv;
34509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34510         this_ptr_conv.is_owned = false;
34511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34512         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34513         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
34514         uint64_t ret_ref = (uint64_t)ret_copy;
34515         return ret_ref;
34516 }
34517
34518 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
34519         LDKRouteHintHop this_ptr_conv;
34520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34521         this_ptr_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34524         CHECK_ACCESS(val_ptr);
34525         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34526         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34527         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34528 }
34529
34530 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) {
34531         LDKPublicKey src_node_id_arg_ref;
34532         CHECK(src_node_id_arg->arr_len == 33);
34533         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33);
34534         LDKRoutingFees fees_arg_conv;
34535         fees_arg_conv.inner = (void*)(fees_arg & (~1));
34536         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
34537         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
34538         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
34539         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
34540         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
34541         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
34542         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
34543         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
34544         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
34545         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
34546         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
34547         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);
34548         uint64_t ret_ref = 0;
34549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34552         ret_ref = (uint64_t)ret_var.inner;
34553         if (ret_var.is_owned) {
34554                 ret_ref |= 1;
34555         }
34556         return ret_ref;
34557 }
34558
34559 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
34560         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
34561 uint64_t ret_ref = 0;
34562 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34563 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
34566 if (ret_var.is_owned) {
34567         ret_ref |= 1;
34568 }
34569         return ret_ref;
34570 }
34571 int64_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
34572         LDKRouteHintHop arg_conv;
34573         arg_conv.inner = (void*)(arg & (~1));
34574         arg_conv.is_owned = false;
34575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34576         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
34577         return ret_val;
34578 }
34579
34580 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
34581         LDKRouteHintHop orig_conv;
34582         orig_conv.inner = (void*)(orig & (~1));
34583         orig_conv.is_owned = false;
34584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34585         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
34586         uint64_t ret_ref = 0;
34587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34590         ret_ref = (uint64_t)ret_var.inner;
34591         if (ret_var.is_owned) {
34592                 ret_ref |= 1;
34593         }
34594         return ret_ref;
34595 }
34596
34597 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
34598         LDKRouteHintHop o_conv;
34599         o_conv.inner = (void*)(o & (~1));
34600         o_conv.is_owned = false;
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34602         int64_t ret_val = RouteHintHop_hash(&o_conv);
34603         return ret_val;
34604 }
34605
34606 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
34607         LDKRouteHintHop a_conv;
34608         a_conv.inner = (void*)(a & (~1));
34609         a_conv.is_owned = false;
34610         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34611         LDKRouteHintHop b_conv;
34612         b_conv.inner = (void*)(b & (~1));
34613         b_conv.is_owned = false;
34614         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34615         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
34616         return ret_val;
34617 }
34618
34619 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
34620         LDKRouteHintHop obj_conv;
34621         obj_conv.inner = (void*)(obj & (~1));
34622         obj_conv.is_owned = false;
34623         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34624         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
34625         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
34626         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34627         CVec_u8Z_free(ret_var);
34628         return ret_arr;
34629 }
34630
34631 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
34632         LDKu8slice ser_ref;
34633         ser_ref.datalen = ser->arr_len;
34634         ser_ref.data = ser->elems;
34635         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
34636         *ret_conv = RouteHintHop_read(ser_ref);
34637         return (uint64_t)ret_conv;
34638 }
34639
34640 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) {
34641         LDKPublicKey our_node_pubkey_ref;
34642         CHECK(our_node_pubkey->arr_len == 33);
34643         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33);
34644         LDKRouteParameters params_conv;
34645         params_conv.inner = (void*)(params & (~1));
34646         params_conv.is_owned = false;
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34648         LDKNetworkGraph network_conv;
34649         network_conv.inner = (void*)(network & (~1));
34650         network_conv.is_owned = false;
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
34652         LDKCVec_ChannelDetailsZ first_hops_constr;
34653         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
34654         if (first_hops != 0) {
34655                 first_hops_constr.datalen = first_hops->arr_len;
34656                 if (first_hops_constr.datalen > 0)
34657                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
34658                 else
34659                         first_hops_constr.data = NULL;
34660                 uint32_t* first_hops_vals = first_hops->elems;
34661                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
34662                         uint32_t first_hops_conv_16 = first_hops_vals[q];
34663                         LDKChannelDetails first_hops_conv_16_conv;
34664                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
34665                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
34666                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
34667                         first_hops_constr.data[q] = first_hops_conv_16_conv;
34668                 }
34669                 first_hops_ptr = &first_hops_constr;
34670         }
34671         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34672         CHECK_ACCESS(logger_ptr);
34673         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34674         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
34675         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
34676         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
34677         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
34678         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
34679         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
34680         return (uint64_t)ret_conv;
34681 }
34682
34683 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
34684         if ((this_ptr & 1) != 0) return;
34685         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34686         CHECK_ACCESS(this_ptr_ptr);
34687         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34688         FREE((void*)this_ptr);
34689         Score_free(this_ptr_conv);
34690 }
34691
34692 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
34693         if ((this_ptr & 1) != 0) return;
34694         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34695         CHECK_ACCESS(this_ptr_ptr);
34696         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
34697         FREE((void*)this_ptr);
34698         LockableScore_free(this_ptr_conv);
34699 }
34700
34701 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
34702         LDKMultiThreadedLockableScore this_obj_conv;
34703         this_obj_conv.inner = (void*)(this_obj & (~1));
34704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34706         MultiThreadedLockableScore_free(this_obj_conv);
34707 }
34708
34709 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
34710         void* score_ptr = (void*)(((uint64_t)score) & ~1);
34711         CHECK_ACCESS(score_ptr);
34712         LDKScore score_conv = *(LDKScore*)(score_ptr);
34713         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
34714         uint64_t ret_ref = 0;
34715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34718         ret_ref = (uint64_t)ret_var.inner;
34719         if (ret_var.is_owned) {
34720                 ret_ref |= 1;
34721         }
34722         return ret_ref;
34723 }
34724
34725 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
34726         LDKScoringParameters this_obj_conv;
34727         this_obj_conv.inner = (void*)(this_obj & (~1));
34728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34730         ScoringParameters_free(this_obj_conv);
34731 }
34732
34733 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
34734         LDKScoringParameters this_ptr_conv;
34735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34736         this_ptr_conv.is_owned = false;
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34738         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
34739         return ret_val;
34740 }
34741
34742 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
34743         LDKScoringParameters this_ptr_conv;
34744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34745         this_ptr_conv.is_owned = false;
34746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34747         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
34748 }
34749
34750 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
34751         LDKScoringParameters this_ptr_conv;
34752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34753         this_ptr_conv.is_owned = false;
34754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34755         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
34756         return ret_val;
34757 }
34758
34759 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
34760         LDKScoringParameters this_ptr_conv;
34761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34762         this_ptr_conv.is_owned = false;
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34764         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
34765 }
34766
34767 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
34768         LDKScoringParameters this_ptr_conv;
34769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34770         this_ptr_conv.is_owned = false;
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34772         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
34773         return ret_val;
34774 }
34775
34776 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) {
34777         LDKScoringParameters this_ptr_conv;
34778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34779         this_ptr_conv.is_owned = false;
34780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34781         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
34782 }
34783
34784 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) {
34785         LDKScoringParameters this_ptr_conv;
34786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34787         this_ptr_conv.is_owned = false;
34788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34789         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
34790         return ret_val;
34791 }
34792
34793 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) {
34794         LDKScoringParameters this_ptr_conv;
34795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34796         this_ptr_conv.is_owned = false;
34797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34798         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
34799 }
34800
34801 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
34802         LDKScoringParameters this_ptr_conv;
34803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34804         this_ptr_conv.is_owned = false;
34805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34806         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
34807         return ret_val;
34808 }
34809
34810 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) {
34811         LDKScoringParameters this_ptr_conv;
34812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34813         this_ptr_conv.is_owned = false;
34814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34815         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
34816 }
34817
34818 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) {
34819         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);
34820         uint64_t ret_ref = 0;
34821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34824         ret_ref = (uint64_t)ret_var.inner;
34825         if (ret_var.is_owned) {
34826                 ret_ref |= 1;
34827         }
34828         return ret_ref;
34829 }
34830
34831 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
34832         LDKScoringParameters obj_conv;
34833         obj_conv.inner = (void*)(obj & (~1));
34834         obj_conv.is_owned = false;
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34836         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
34837         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen);
34838         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34839         CVec_u8Z_free(ret_var);
34840         return ret_arr;
34841 }
34842
34843 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
34844         LDKu8slice ser_ref;
34845         ser_ref.datalen = ser->arr_len;
34846         ser_ref.data = ser->elems;
34847         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
34848         *ret_conv = ScoringParameters_read(ser_ref);
34849         return (uint64_t)ret_conv;
34850 }
34851
34852 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
34853         LDKScoringParameters ret_var = ScoringParameters_default();
34854         uint64_t ret_ref = 0;
34855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34858         ret_ref = (uint64_t)ret_var.inner;
34859         if (ret_var.is_owned) {
34860                 ret_ref |= 1;
34861         }
34862         return ret_ref;
34863 }
34864