[TS] Update auto-generated bindings
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint32_t arr_len; \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKCreationError_DescriptionTooLong;
158                 case 1: return LDKCreationError_RouteTooLong;
159                 case 2: return LDKCreationError_TimestampOutOfBounds;
160                 case 3: return LDKCreationError_InvalidAmount;
161                 case 4: return LDKCreationError_MissingRouteHints;
162         }
163         abort();
164 }
165 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
166         switch (val) {
167                 case LDKCreationError_DescriptionTooLong: return 0;
168                 case LDKCreationError_RouteTooLong: return 1;
169                 case LDKCreationError_TimestampOutOfBounds: return 2;
170                 case LDKCreationError_InvalidAmount: return 3;
171                 case LDKCreationError_MissingRouteHints: return 4;
172                 default: abort();
173         }
174 }
175 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKCurrency_Bitcoin;
178                 case 1: return LDKCurrency_BitcoinTestnet;
179                 case 2: return LDKCurrency_Regtest;
180                 case 3: return LDKCurrency_Simnet;
181                 case 4: return LDKCurrency_Signet;
182         }
183         abort();
184 }
185 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
186         switch (val) {
187                 case LDKCurrency_Bitcoin: return 0;
188                 case LDKCurrency_BitcoinTestnet: return 1;
189                 case LDKCurrency_Regtest: return 2;
190                 case LDKCurrency_Simnet: return 3;
191                 case LDKCurrency_Signet: return 4;
192                 default: abort();
193         }
194 }
195 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKLevel_Gossip;
198                 case 1: return LDKLevel_Trace;
199                 case 2: return LDKLevel_Debug;
200                 case 3: return LDKLevel_Info;
201                 case 4: return LDKLevel_Warn;
202                 case 5: return LDKLevel_Error;
203         }
204         abort();
205 }
206 static inline int32_t LDKLevel_to_js(LDKLevel val) {
207         switch (val) {
208                 case LDKLevel_Gossip: return 0;
209                 case LDKLevel_Trace: return 1;
210                 case LDKLevel_Debug: return 2;
211                 case LDKLevel_Info: return 3;
212                 case LDKLevel_Warn: return 4;
213                 case LDKLevel_Error: return 5;
214                 default: abort();
215         }
216 }
217 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
218         switch (ord) {
219                 case 0: return LDKNetwork_Bitcoin;
220                 case 1: return LDKNetwork_Testnet;
221                 case 2: return LDKNetwork_Regtest;
222                 case 3: return LDKNetwork_Signet;
223         }
224         abort();
225 }
226 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
227         switch (val) {
228                 case LDKNetwork_Bitcoin: return 0;
229                 case LDKNetwork_Testnet: return 1;
230                 case LDKNetwork_Regtest: return 2;
231                 case LDKNetwork_Signet: return 3;
232                 default: abort();
233         }
234 }
235 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
236         switch (ord) {
237                 case 0: return LDKRecipient_Node;
238                 case 1: return LDKRecipient_PhantomNode;
239         }
240         abort();
241 }
242 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
243         switch (val) {
244                 case LDKRecipient_Node: return 0;
245                 case LDKRecipient_PhantomNode: return 1;
246                 default: abort();
247         }
248 }
249 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
250         switch (ord) {
251                 case 0: return LDKSecp256k1Error_IncorrectSignature;
252                 case 1: return LDKSecp256k1Error_InvalidMessage;
253                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
254                 case 3: return LDKSecp256k1Error_InvalidSignature;
255                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
256                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
257                 case 6: return LDKSecp256k1Error_InvalidTweak;
258                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
259                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
260         }
261         abort();
262 }
263 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
264         switch (val) {
265                 case LDKSecp256k1Error_IncorrectSignature: return 0;
266                 case LDKSecp256k1Error_InvalidMessage: return 1;
267                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
268                 case LDKSecp256k1Error_InvalidSignature: return 3;
269                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
270                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
271                 case LDKSecp256k1Error_InvalidTweak: return 6;
272                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
273                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
274                 default: abort();
275         }
276 }
277 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
278         switch (ord) {
279                 case 0: return LDKSemanticError_NoPaymentHash;
280                 case 1: return LDKSemanticError_MultiplePaymentHashes;
281                 case 2: return LDKSemanticError_NoDescription;
282                 case 3: return LDKSemanticError_MultipleDescriptions;
283                 case 4: return LDKSemanticError_NoPaymentSecret;
284                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
285                 case 6: return LDKSemanticError_InvalidFeatures;
286                 case 7: return LDKSemanticError_InvalidRecoveryId;
287                 case 8: return LDKSemanticError_InvalidSignature;
288                 case 9: return LDKSemanticError_ImpreciseAmount;
289         }
290         abort();
291 }
292 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
293         switch (val) {
294                 case LDKSemanticError_NoPaymentHash: return 0;
295                 case LDKSemanticError_MultiplePaymentHashes: return 1;
296                 case LDKSemanticError_NoDescription: return 2;
297                 case LDKSemanticError_MultipleDescriptions: return 3;
298                 case LDKSemanticError_NoPaymentSecret: return 4;
299                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
300                 case LDKSemanticError_InvalidFeatures: return 6;
301                 case LDKSemanticError_InvalidRecoveryId: return 7;
302                 case LDKSemanticError_InvalidSignature: return 8;
303                 case LDKSemanticError_ImpreciseAmount: return 9;
304                 default: abort();
305         }
306 }
307 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
308         switch (ord) {
309                 case 0: return LDKSiPrefix_Milli;
310                 case 1: return LDKSiPrefix_Micro;
311                 case 2: return LDKSiPrefix_Nano;
312                 case 3: return LDKSiPrefix_Pico;
313         }
314         abort();
315 }
316 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
317         switch (val) {
318                 case LDKSiPrefix_Milli: return 0;
319                 case LDKSiPrefix_Micro: return 1;
320                 case LDKSiPrefix_Nano: return 2;
321                 case LDKSiPrefix_Pico: return 3;
322                 default: abort();
323         }
324 }
325 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
326         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
327         switch(obj->tag) {
328                 case LDKBech32Error_MissingSeparator: return 0;
329                 case LDKBech32Error_InvalidChecksum: return 1;
330                 case LDKBech32Error_InvalidLength: return 2;
331                 case LDKBech32Error_InvalidChar: return 3;
332                 case LDKBech32Error_InvalidData: return 4;
333                 case LDKBech32Error_InvalidPadding: return 5;
334                 case LDKBech32Error_MixedCase: return 6;
335                 default: abort();
336         }
337 }
338 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
339         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
340         assert(obj->tag == LDKBech32Error_InvalidChar);
341         return obj->invalid_char;
342 }
343 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
344         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
345         assert(obj->tag == LDKBech32Error_InvalidData);
346         return obj->invalid_data;
347 }
348 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
349         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
350         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
351         return ret;
352 }
353 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) {
354         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
355         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
356         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
357         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
358         CVec_u8Z_free(ret_var);
359         return ret_arr;
360 }
361
362 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) {
363         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
364         int64_t ret_val = TxOut_get_value(thing_conv);
365         return ret_val;
366 }
367
368 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
369 CHECK(owner->result_ok);
370         return *owner->contents.result;
371 }
372 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
373         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
374         CResult_NoneNoneZ_get_ok(owner_conv);
375 }
376
377 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
378 CHECK(!owner->result_ok);
379         return *owner->contents.err;
380 }
381 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
382         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
383         CResult_NoneNoneZ_get_err(owner_conv);
384 }
385
386 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
387 CHECK(owner->result_ok);
388         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
389 }
390 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
391         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
392         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
393         uint32_t ret_ref = 0;
394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
397         ret_ref = (uintptr_t)ret_var.inner;
398         if (ret_var.is_owned) {
399                 ret_ref |= 1;
400         }
401         return ret_ref;
402 }
403
404 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
405 CHECK(!owner->result_ok);
406         return DecodeError_clone(&*owner->contents.err);
407 }
408 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
409         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
410         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
411         uint32_t ret_ref = 0;
412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
415         ret_ref = (uintptr_t)ret_var.inner;
416         if (ret_var.is_owned) {
417                 ret_ref |= 1;
418         }
419         return ret_ref;
420 }
421
422 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
423 CHECK(owner->result_ok);
424         return *owner->contents.result;
425 }
426 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
427         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
428         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
429         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
430         return ret_arr;
431 }
432
433 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
434 CHECK(!owner->result_ok);
435         return *owner->contents.err;
436 }
437 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
438         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
439         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
440         return ret_conv;
441 }
442
443 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
444 CHECK(owner->result_ok);
445         return *owner->contents.result;
446 }
447 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
448         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
449         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
450         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
451         return ret_arr;
452 }
453
454 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
455 CHECK(!owner->result_ok);
456         return *owner->contents.err;
457 }
458 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
459         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
460         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
461         return ret_conv;
462 }
463
464 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
465 CHECK(owner->result_ok);
466         return TxCreationKeys_clone(&*owner->contents.result);
467 }
468 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
469         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
470         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
471         uint32_t ret_ref = 0;
472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
475         ret_ref = (uintptr_t)ret_var.inner;
476         if (ret_var.is_owned) {
477                 ret_ref |= 1;
478         }
479         return ret_ref;
480 }
481
482 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
483 CHECK(!owner->result_ok);
484         return DecodeError_clone(&*owner->contents.err);
485 }
486 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
487         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
488         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
489         uint32_t ret_ref = 0;
490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
493         ret_ref = (uintptr_t)ret_var.inner;
494         if (ret_var.is_owned) {
495                 ret_ref |= 1;
496         }
497         return ret_ref;
498 }
499
500 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
501 CHECK(owner->result_ok);
502         return ChannelPublicKeys_clone(&*owner->contents.result);
503 }
504 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
505         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
506         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
507         uint32_t ret_ref = 0;
508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
511         ret_ref = (uintptr_t)ret_var.inner;
512         if (ret_var.is_owned) {
513                 ret_ref |= 1;
514         }
515         return ret_ref;
516 }
517
518 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
519 CHECK(!owner->result_ok);
520         return DecodeError_clone(&*owner->contents.err);
521 }
522 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
523         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
524         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
525         uint32_t ret_ref = 0;
526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
529         ret_ref = (uintptr_t)ret_var.inner;
530         if (ret_var.is_owned) {
531                 ret_ref |= 1;
532         }
533         return ret_ref;
534 }
535
536 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
537 CHECK(owner->result_ok);
538         return TxCreationKeys_clone(&*owner->contents.result);
539 }
540 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
541         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
542         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
543         uint32_t ret_ref = 0;
544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
547         ret_ref = (uintptr_t)ret_var.inner;
548         if (ret_var.is_owned) {
549                 ret_ref |= 1;
550         }
551         return ret_ref;
552 }
553
554 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
555 CHECK(!owner->result_ok);
556         return *owner->contents.err;
557 }
558 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
559         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
560         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
561         return ret_conv;
562 }
563
564 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
565         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
566         switch(obj->tag) {
567                 case LDKCOption_u32Z_Some: return 0;
568                 case LDKCOption_u32Z_None: return 1;
569                 default: abort();
570         }
571 }
572 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
573         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
574         assert(obj->tag == LDKCOption_u32Z_Some);
575         return obj->some;
576 }
577 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
578 CHECK(owner->result_ok);
579         return HTLCOutputInCommitment_clone(&*owner->contents.result);
580 }
581 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
582         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
583         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
584         uint32_t ret_ref = 0;
585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
588         ret_ref = (uintptr_t)ret_var.inner;
589         if (ret_var.is_owned) {
590                 ret_ref |= 1;
591         }
592         return ret_ref;
593 }
594
595 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
596 CHECK(!owner->result_ok);
597         return DecodeError_clone(&*owner->contents.err);
598 }
599 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
600         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
601         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
602         uint32_t ret_ref = 0;
603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
606         ret_ref = (uintptr_t)ret_var.inner;
607         if (ret_var.is_owned) {
608                 ret_ref |= 1;
609         }
610         return ret_ref;
611 }
612
613 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
614 CHECK(owner->result_ok);
615         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
616 }
617 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
618         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
619         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
620         uint32_t ret_ref = 0;
621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
624         ret_ref = (uintptr_t)ret_var.inner;
625         if (ret_var.is_owned) {
626                 ret_ref |= 1;
627         }
628         return ret_ref;
629 }
630
631 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
632 CHECK(!owner->result_ok);
633         return DecodeError_clone(&*owner->contents.err);
634 }
635 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
636         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
637         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
638         uint32_t ret_ref = 0;
639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
642         ret_ref = (uintptr_t)ret_var.inner;
643         if (ret_var.is_owned) {
644                 ret_ref |= 1;
645         }
646         return ret_ref;
647 }
648
649 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
650 CHECK(owner->result_ok);
651         return ChannelTransactionParameters_clone(&*owner->contents.result);
652 }
653 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
654         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
655         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
656         uint32_t ret_ref = 0;
657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
660         ret_ref = (uintptr_t)ret_var.inner;
661         if (ret_var.is_owned) {
662                 ret_ref |= 1;
663         }
664         return ret_ref;
665 }
666
667 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
668 CHECK(!owner->result_ok);
669         return DecodeError_clone(&*owner->contents.err);
670 }
671 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
672         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
673         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
674         uint32_t ret_ref = 0;
675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
678         ret_ref = (uintptr_t)ret_var.inner;
679         if (ret_var.is_owned) {
680                 ret_ref |= 1;
681         }
682         return ret_ref;
683 }
684
685 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
686 CHECK(owner->result_ok);
687         return HolderCommitmentTransaction_clone(&*owner->contents.result);
688 }
689 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
690         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
691         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
692         uint32_t ret_ref = 0;
693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
696         ret_ref = (uintptr_t)ret_var.inner;
697         if (ret_var.is_owned) {
698                 ret_ref |= 1;
699         }
700         return ret_ref;
701 }
702
703 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
704 CHECK(!owner->result_ok);
705         return DecodeError_clone(&*owner->contents.err);
706 }
707 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
708         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
709         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
710         uint32_t ret_ref = 0;
711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
714         ret_ref = (uintptr_t)ret_var.inner;
715         if (ret_var.is_owned) {
716                 ret_ref |= 1;
717         }
718         return ret_ref;
719 }
720
721 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
722 CHECK(owner->result_ok);
723         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
724 }
725 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
726         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
727         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
728         uint32_t ret_ref = 0;
729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
732         ret_ref = (uintptr_t)ret_var.inner;
733         if (ret_var.is_owned) {
734                 ret_ref |= 1;
735         }
736         return ret_ref;
737 }
738
739 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
740 CHECK(!owner->result_ok);
741         return DecodeError_clone(&*owner->contents.err);
742 }
743 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
744         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
745         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
746         uint32_t ret_ref = 0;
747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
750         ret_ref = (uintptr_t)ret_var.inner;
751         if (ret_var.is_owned) {
752                 ret_ref |= 1;
753         }
754         return ret_ref;
755 }
756
757 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
758 CHECK(owner->result_ok);
759         return &*owner->contents.result;
760 }
761 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
762         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
763         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
764         uint32_t ret_ref = 0;
765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
768         ret_ref = (uintptr_t)ret_var.inner & ~1;
769         return ret_ref;
770 }
771
772 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
773 CHECK(!owner->result_ok);
774         return *owner->contents.err;
775 }
776 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
777         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
778         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
779 }
780
781 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
782 CHECK(owner->result_ok);
783         return CommitmentTransaction_clone(&*owner->contents.result);
784 }
785 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
786         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
787         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
788         uint32_t ret_ref = 0;
789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
792         ret_ref = (uintptr_t)ret_var.inner;
793         if (ret_var.is_owned) {
794                 ret_ref |= 1;
795         }
796         return ret_ref;
797 }
798
799 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
800 CHECK(!owner->result_ok);
801         return DecodeError_clone(&*owner->contents.err);
802 }
803 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
804         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
805         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
806         uint32_t ret_ref = 0;
807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
810         ret_ref = (uintptr_t)ret_var.inner;
811         if (ret_var.is_owned) {
812                 ret_ref |= 1;
813         }
814         return ret_ref;
815 }
816
817 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
818 CHECK(owner->result_ok);
819         return &*owner->contents.result;
820 }
821 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
822         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
823         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
824         uint32_t ret_ref = 0;
825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
828         ret_ref = (uintptr_t)ret_var.inner & ~1;
829         return ret_ref;
830 }
831
832 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
833 CHECK(!owner->result_ok);
834         return *owner->contents.err;
835 }
836 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
837         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
838         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
839 }
840
841 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
842 CHECK(owner->result_ok);
843         return *owner->contents.result;
844 }
845 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
846         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
847         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
848         ptrArray ret_arr = NULL;
849         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
850         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
851         for (size_t m = 0; m < ret_var.datalen; m++) {
852                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
853                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
854                 ret_arr_ptr[m] = ret_conv_12_arr;
855         }
856         
857         return ret_arr;
858 }
859
860 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
861 CHECK(!owner->result_ok);
862         return *owner->contents.err;
863 }
864 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
865         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
866         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
867 }
868
869 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
870 CHECK(owner->result_ok);
871         return ShutdownScript_clone(&*owner->contents.result);
872 }
873 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
874         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
875         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
876         uint32_t ret_ref = 0;
877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
880         ret_ref = (uintptr_t)ret_var.inner;
881         if (ret_var.is_owned) {
882                 ret_ref |= 1;
883         }
884         return ret_ref;
885 }
886
887 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
888 CHECK(!owner->result_ok);
889         return DecodeError_clone(&*owner->contents.err);
890 }
891 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
892         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
893         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
894         uint32_t ret_ref = 0;
895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
898         ret_ref = (uintptr_t)ret_var.inner;
899         if (ret_var.is_owned) {
900                 ret_ref |= 1;
901         }
902         return ret_ref;
903 }
904
905 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
906 CHECK(owner->result_ok);
907         return ShutdownScript_clone(&*owner->contents.result);
908 }
909 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
910         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
911         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
912         uint32_t ret_ref = 0;
913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
916         ret_ref = (uintptr_t)ret_var.inner;
917         if (ret_var.is_owned) {
918                 ret_ref |= 1;
919         }
920         return ret_ref;
921 }
922
923 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
924 CHECK(!owner->result_ok);
925         return InvalidShutdownScript_clone(&*owner->contents.err);
926 }
927 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
928         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
929         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
930         uint32_t ret_ref = 0;
931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
934         ret_ref = (uintptr_t)ret_var.inner;
935         if (ret_var.is_owned) {
936                 ret_ref |= 1;
937         }
938         return ret_ref;
939 }
940
941 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
942 CHECK(owner->result_ok);
943         return RouteHop_clone(&*owner->contents.result);
944 }
945 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
946         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
947         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
948         uint32_t ret_ref = 0;
949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
952         ret_ref = (uintptr_t)ret_var.inner;
953         if (ret_var.is_owned) {
954                 ret_ref |= 1;
955         }
956         return ret_ref;
957 }
958
959 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
960 CHECK(!owner->result_ok);
961         return DecodeError_clone(&*owner->contents.err);
962 }
963 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
964         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
965         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
966         uint32_t ret_ref = 0;
967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
970         ret_ref = (uintptr_t)ret_var.inner;
971         if (ret_var.is_owned) {
972                 ret_ref |= 1;
973         }
974         return ret_ref;
975 }
976
977 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
978         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
979         for (size_t i = 0; i < ret.datalen; i++) {
980                 ret.data[i] = RouteHop_clone(&orig->data[i]);
981         }
982         return ret;
983 }
984 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
985         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
986         for (size_t i = 0; i < ret.datalen; i++) {
987                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
988         }
989         return ret;
990 }
991 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
992 CHECK(owner->result_ok);
993         return Route_clone(&*owner->contents.result);
994 }
995 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
996         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
997         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
998         uint32_t ret_ref = 0;
999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1002         ret_ref = (uintptr_t)ret_var.inner;
1003         if (ret_var.is_owned) {
1004                 ret_ref |= 1;
1005         }
1006         return ret_ref;
1007 }
1008
1009 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1010 CHECK(!owner->result_ok);
1011         return DecodeError_clone(&*owner->contents.err);
1012 }
1013 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1014         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1015         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1016         uint32_t ret_ref = 0;
1017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1020         ret_ref = (uintptr_t)ret_var.inner;
1021         if (ret_var.is_owned) {
1022                 ret_ref |= 1;
1023         }
1024         return ret_ref;
1025 }
1026
1027 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1028 CHECK(owner->result_ok);
1029         return RouteParameters_clone(&*owner->contents.result);
1030 }
1031 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1032         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1033         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1034         uint32_t ret_ref = 0;
1035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1038         ret_ref = (uintptr_t)ret_var.inner;
1039         if (ret_var.is_owned) {
1040                 ret_ref |= 1;
1041         }
1042         return ret_ref;
1043 }
1044
1045 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1046 CHECK(!owner->result_ok);
1047         return DecodeError_clone(&*owner->contents.err);
1048 }
1049 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1050         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1051         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1052         uint32_t ret_ref = 0;
1053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1056         ret_ref = (uintptr_t)ret_var.inner;
1057         if (ret_var.is_owned) {
1058                 ret_ref |= 1;
1059         }
1060         return ret_ref;
1061 }
1062
1063 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1064         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1065         for (size_t i = 0; i < ret.datalen; i++) {
1066                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1067         }
1068         return ret;
1069 }
1070 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1071         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1072         switch(obj->tag) {
1073                 case LDKCOption_u64Z_Some: return 0;
1074                 case LDKCOption_u64Z_None: return 1;
1075                 default: abort();
1076         }
1077 }
1078 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1079         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1080         assert(obj->tag == LDKCOption_u64Z_Some);
1081         return obj->some;
1082 }
1083 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1084 CHECK(owner->result_ok);
1085         return PaymentParameters_clone(&*owner->contents.result);
1086 }
1087 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1088         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1089         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1090         uint32_t ret_ref = 0;
1091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1094         ret_ref = (uintptr_t)ret_var.inner;
1095         if (ret_var.is_owned) {
1096                 ret_ref |= 1;
1097         }
1098         return ret_ref;
1099 }
1100
1101 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1102 CHECK(!owner->result_ok);
1103         return DecodeError_clone(&*owner->contents.err);
1104 }
1105 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1106         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1107         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1108         uint32_t ret_ref = 0;
1109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1112         ret_ref = (uintptr_t)ret_var.inner;
1113         if (ret_var.is_owned) {
1114                 ret_ref |= 1;
1115         }
1116         return ret_ref;
1117 }
1118
1119 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1120         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1121         for (size_t i = 0; i < ret.datalen; i++) {
1122                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1123         }
1124         return ret;
1125 }
1126 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1127 CHECK(owner->result_ok);
1128         return RouteHint_clone(&*owner->contents.result);
1129 }
1130 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1131         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1132         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1133         uint32_t ret_ref = 0;
1134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1135         CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
1138         if (ret_var.is_owned) {
1139                 ret_ref |= 1;
1140         }
1141         return ret_ref;
1142 }
1143
1144 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1145 CHECK(!owner->result_ok);
1146         return DecodeError_clone(&*owner->contents.err);
1147 }
1148 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1149         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1150         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1151         uint32_t ret_ref = 0;
1152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1155         ret_ref = (uintptr_t)ret_var.inner;
1156         if (ret_var.is_owned) {
1157                 ret_ref |= 1;
1158         }
1159         return ret_ref;
1160 }
1161
1162 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1163 CHECK(owner->result_ok);
1164         return RouteHintHop_clone(&*owner->contents.result);
1165 }
1166 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1167         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1168         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1169         uint32_t ret_ref = 0;
1170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1173         ret_ref = (uintptr_t)ret_var.inner;
1174         if (ret_var.is_owned) {
1175                 ret_ref |= 1;
1176         }
1177         return ret_ref;
1178 }
1179
1180 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1181 CHECK(!owner->result_ok);
1182         return DecodeError_clone(&*owner->contents.err);
1183 }
1184 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1185         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1186         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1187         uint32_t ret_ref = 0;
1188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1191         ret_ref = (uintptr_t)ret_var.inner;
1192         if (ret_var.is_owned) {
1193                 ret_ref |= 1;
1194         }
1195         return ret_ref;
1196 }
1197
1198 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1199         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1200         for (size_t i = 0; i < ret.datalen; i++) {
1201                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1202         }
1203         return ret;
1204 }
1205 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1206 CHECK(owner->result_ok);
1207         return Route_clone(&*owner->contents.result);
1208 }
1209 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1210         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1211         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1212         uint32_t ret_ref = 0;
1213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1216         ret_ref = (uintptr_t)ret_var.inner;
1217         if (ret_var.is_owned) {
1218                 ret_ref |= 1;
1219         }
1220         return ret_ref;
1221 }
1222
1223 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1224 CHECK(!owner->result_ok);
1225         return LightningError_clone(&*owner->contents.err);
1226 }
1227 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1228         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1229         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1230         uint32_t ret_ref = 0;
1231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1234         ret_ref = (uintptr_t)ret_var.inner;
1235         if (ret_var.is_owned) {
1236                 ret_ref |= 1;
1237         }
1238         return ret_ref;
1239 }
1240
1241 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1242 CHECK(owner->result_ok);
1243         return TxOut_clone(&*owner->contents.result);
1244 }
1245 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1246         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1247         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1248         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1249         return (uint32_t)ret_ref;
1250 }
1251
1252 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1253 CHECK(!owner->result_ok);
1254         return AccessError_clone(&*owner->contents.err);
1255 }
1256 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1257         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1258         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1259         return ret_conv;
1260 }
1261
1262 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1263         return owner->a;
1264 }
1265 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1266         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1267         uint32_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1268         return ret_val;
1269 }
1270
1271 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1272         return owner->b;
1273 }
1274 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1275         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1276         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1277         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1278         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1279         return ret_arr;
1280 }
1281
1282 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1283         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1284         for (size_t i = 0; i < ret.datalen; i++) {
1285                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1286         }
1287         return ret;
1288 }
1289 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1290         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1291         for (size_t i = 0; i < ret.datalen; i++) {
1292                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1293         }
1294         return ret;
1295 }
1296 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1297 CHECK(owner->result_ok);
1298         return *owner->contents.result;
1299 }
1300 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1301         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1302         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1303 }
1304
1305 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1306 CHECK(!owner->result_ok);
1307         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1308 }
1309 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1310         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1311         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1312         return ret_conv;
1313 }
1314
1315 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1316         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1317         switch(obj->tag) {
1318                 case LDKMonitorEvent_HTLCEvent: return 0;
1319                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1320                 case LDKMonitorEvent_UpdateCompleted: return 2;
1321                 case LDKMonitorEvent_UpdateFailed: return 3;
1322                 default: abort();
1323         }
1324 }
1325 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1326         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1327         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1328                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1329                         uint32_t htlc_event_ref = 0;
1330                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1331                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1333                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1334         return htlc_event_ref;
1335 }
1336 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1337         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1338         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1339                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1340                         uint32_t commitment_tx_confirmed_ref = 0;
1341                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1342                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1344                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1345         return commitment_tx_confirmed_ref;
1346 }
1347 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1348         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1349         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1350                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1351                         uint32_t funding_txo_ref = 0;
1352                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1353                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1354                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1355                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1356         return funding_txo_ref;
1357 }
1358 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1359         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1360         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1361         return obj->update_completed.monitor_update_id;
1362 }
1363 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1364         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1365         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1366                         LDKOutPoint update_failed_var = obj->update_failed;
1367                         uint32_t update_failed_ref = 0;
1368                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1371                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1372         return update_failed_ref;
1373 }
1374 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1375         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1376         for (size_t i = 0; i < ret.datalen; i++) {
1377                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1378         }
1379         return ret;
1380 }
1381 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1382         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1383         switch(obj->tag) {
1384                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1385                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1386                 default: abort();
1387         }
1388 }
1389 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1390         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1391         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1392                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1393                         *some_conv = obj->some;
1394                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1395         return ((uint32_t)some_conv);
1396 }
1397 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1398         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1399         switch(obj->tag) {
1400                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1401                 case LDKClosureReason_HolderForceClosed: return 1;
1402                 case LDKClosureReason_CooperativeClosure: return 2;
1403                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1404                 case LDKClosureReason_FundingTimedOut: return 4;
1405                 case LDKClosureReason_ProcessingError: return 5;
1406                 case LDKClosureReason_DisconnectedPeer: return 6;
1407                 case LDKClosureReason_OutdatedChannelManager: return 7;
1408                 default: abort();
1409         }
1410 }
1411 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1412         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1413         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1414                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1415                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1416         return peer_msg_conv;
1417 }
1418 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1419         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1420         assert(obj->tag == LDKClosureReason_ProcessingError);
1421                         LDKStr err_str = obj->processing_error.err;
1422                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1423         return err_conv;
1424 }
1425 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1426         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1427         switch(obj->tag) {
1428                 case LDKCOption_ClosureReasonZ_Some: return 0;
1429                 case LDKCOption_ClosureReasonZ_None: return 1;
1430                 default: abort();
1431         }
1432 }
1433 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1434         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1435         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1436                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1437         return some_ref;
1438 }
1439 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1440 CHECK(owner->result_ok);
1441         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1442 }
1443 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1444         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1445         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1446         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1447         uint32_t ret_ref = (uintptr_t)ret_copy;
1448         return ret_ref;
1449 }
1450
1451 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1452 CHECK(!owner->result_ok);
1453         return DecodeError_clone(&*owner->contents.err);
1454 }
1455 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1456         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1457         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1458         uint32_t ret_ref = 0;
1459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1462         ret_ref = (uintptr_t)ret_var.inner;
1463         if (ret_var.is_owned) {
1464                 ret_ref |= 1;
1465         }
1466         return ret_ref;
1467 }
1468
1469 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1470         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1471         switch(obj->tag) {
1472                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1473                 case LDKNetworkUpdate_ChannelClosed: return 1;
1474                 case LDKNetworkUpdate_NodeFailure: return 2;
1475                 default: abort();
1476         }
1477 }
1478 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1479         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1480         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1481                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1482                         uint32_t msg_ref = 0;
1483                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1484                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1485                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1486                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1487         return msg_ref;
1488 }
1489 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1490         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1491         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1492         return obj->channel_closed.short_channel_id;
1493 }
1494 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1495         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1496         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1497         return obj->channel_closed.is_permanent;
1498 }
1499 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1500         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1501         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1502                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1503                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1504         return node_id_arr;
1505 }
1506 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1507         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1508         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1509         return obj->node_failure.is_permanent;
1510 }
1511 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1512         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1513         switch(obj->tag) {
1514                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1515                 case LDKCOption_NetworkUpdateZ_None: return 1;
1516                 default: abort();
1517         }
1518 }
1519 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1520         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1521         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1522                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1523         return some_ref;
1524 }
1525 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1526         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1527         switch(obj->tag) {
1528                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1529                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1530                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1531                 default: abort();
1532         }
1533 }
1534 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1535         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1536         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1537                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1538                         uint32_t outpoint_ref = 0;
1539                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1540                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1541                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1542                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1543         return outpoint_ref;
1544 }
1545 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1546         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1547         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1548                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1549         return (uint32_t)output_ref;
1550 }
1551 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1552         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1553         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1554                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1555                         uint32_t delayed_payment_output_ref = 0;
1556                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1557                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1558                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1559                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1560         return delayed_payment_output_ref;
1561 }
1562 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1563         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1564         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1565                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1566                         uint32_t static_payment_output_ref = 0;
1567                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1568                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1569                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1570                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1571         return static_payment_output_ref;
1572 }
1573 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1574         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1575         for (size_t i = 0; i < ret.datalen; i++) {
1576                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1577         }
1578         return ret;
1579 }
1580 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1581         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1582         switch(obj->tag) {
1583                 case LDKPaymentPurpose_InvoicePayment: return 0;
1584                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1585                 default: abort();
1586         }
1587 }
1588 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1589         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1590         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1591                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1592                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1593         return payment_preimage_arr;
1594 }
1595 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1596         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1597         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1598                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1599                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1600         return payment_secret_arr;
1601 }
1602 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1603         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1604         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1605                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1606                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1607         return spontaneous_payment_arr;
1608 }
1609 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1610         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1611         switch(obj->tag) {
1612                 case LDKEvent_FundingGenerationReady: return 0;
1613                 case LDKEvent_PaymentReceived: return 1;
1614                 case LDKEvent_PaymentSent: return 2;
1615                 case LDKEvent_PaymentPathFailed: return 3;
1616                 case LDKEvent_PaymentFailed: return 4;
1617                 case LDKEvent_PendingHTLCsForwardable: return 5;
1618                 case LDKEvent_SpendableOutputs: return 6;
1619                 case LDKEvent_PaymentForwarded: return 7;
1620                 case LDKEvent_ChannelClosed: return 8;
1621                 case LDKEvent_DiscardFunding: return 9;
1622                 case LDKEvent_PaymentPathSuccessful: return 10;
1623                 case LDKEvent_OpenChannelRequest: return 11;
1624                 default: abort();
1625         }
1626 }
1627 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1628         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1629         assert(obj->tag == LDKEvent_FundingGenerationReady);
1630                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1631                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1632         return temporary_channel_id_arr;
1633 }
1634 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1635         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1636         assert(obj->tag == LDKEvent_FundingGenerationReady);
1637         return obj->funding_generation_ready.channel_value_satoshis;
1638 }
1639 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1640         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1641         assert(obj->tag == LDKEvent_FundingGenerationReady);
1642                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1643                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1644                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1645         return output_script_arr;
1646 }
1647 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1648         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1649         assert(obj->tag == LDKEvent_FundingGenerationReady);
1650         return obj->funding_generation_ready.user_channel_id;
1651 }
1652 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_PaymentReceived);
1655                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1656                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1657         return payment_hash_arr;
1658 }
1659 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_PaymentReceived);
1662         return obj->payment_received.amt;
1663 }
1664 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1665         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1666         assert(obj->tag == LDKEvent_PaymentReceived);
1667                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1668         return purpose_ref;
1669 }
1670 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1671         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1672         assert(obj->tag == LDKEvent_PaymentSent);
1673                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1674                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1675         return payment_id_arr;
1676 }
1677 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1678         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1679         assert(obj->tag == LDKEvent_PaymentSent);
1680                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1681                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1682         return payment_preimage_arr;
1683 }
1684 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1685         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1686         assert(obj->tag == LDKEvent_PaymentSent);
1687                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1688                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1689         return payment_hash_arr;
1690 }
1691 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1692         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1693         assert(obj->tag == LDKEvent_PaymentSent);
1694                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1695         return fee_paid_msat_ref;
1696 }
1697 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1698         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1699         assert(obj->tag == LDKEvent_PaymentPathFailed);
1700                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1701                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1702         return payment_id_arr;
1703 }
1704 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1705         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1706         assert(obj->tag == LDKEvent_PaymentPathFailed);
1707                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1708                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1709         return payment_hash_arr;
1710 }
1711 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1712         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1713         assert(obj->tag == LDKEvent_PaymentPathFailed);
1714         return obj->payment_path_failed.rejected_by_dest;
1715 }
1716 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1717         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1718         assert(obj->tag == LDKEvent_PaymentPathFailed);
1719                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1720         return network_update_ref;
1721 }
1722 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1723         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1724         assert(obj->tag == LDKEvent_PaymentPathFailed);
1725         return obj->payment_path_failed.all_paths_failed;
1726 }
1727 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1728         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1729         assert(obj->tag == LDKEvent_PaymentPathFailed);
1730                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1731                         uint32_tArray path_arr = NULL;
1732                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1733                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1734                         for (size_t k = 0; k < path_var.datalen; k++) {
1735                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1736                                 uint32_t path_conv_10_ref = 0;
1737                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1738                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1739                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1740                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1741                                 path_arr_ptr[k] = path_conv_10_ref;
1742                         }
1743                         
1744         return path_arr;
1745 }
1746 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1747         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1748         assert(obj->tag == LDKEvent_PaymentPathFailed);
1749                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1750         return short_channel_id_ref;
1751 }
1752 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1753         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1754         assert(obj->tag == LDKEvent_PaymentPathFailed);
1755                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1756                         uint32_t retry_ref = 0;
1757                         if ((uintptr_t)retry_var.inner > 4096) {
1758                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1759                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1760                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1761                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1762                         }
1763         return retry_ref;
1764 }
1765 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1766         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1767         assert(obj->tag == LDKEvent_PaymentFailed);
1768                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1769                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1770         return payment_id_arr;
1771 }
1772 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1773         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1774         assert(obj->tag == LDKEvent_PaymentFailed);
1775                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1776                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1777         return payment_hash_arr;
1778 }
1779 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1780         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1781         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1782         return obj->pending_htl_cs_forwardable.time_forwardable;
1783 }
1784 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1785         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1786         assert(obj->tag == LDKEvent_SpendableOutputs);
1787                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1788                         uint32_tArray outputs_arr = NULL;
1789                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1790                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1791                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1792                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1793                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1794                         }
1795                         
1796         return outputs_arr;
1797 }
1798 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1800         assert(obj->tag == LDKEvent_PaymentForwarded);
1801                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1802         return fee_earned_msat_ref;
1803 }
1804 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1805         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1806         assert(obj->tag == LDKEvent_PaymentForwarded);
1807         return obj->payment_forwarded.claim_from_onchain_tx;
1808 }
1809 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1810         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1811         assert(obj->tag == LDKEvent_ChannelClosed);
1812                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1813                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1814         return channel_id_arr;
1815 }
1816 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1817         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1818         assert(obj->tag == LDKEvent_ChannelClosed);
1819         return obj->channel_closed.user_channel_id;
1820 }
1821 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1822         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1823         assert(obj->tag == LDKEvent_ChannelClosed);
1824                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1825         return reason_ref;
1826 }
1827 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1828         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1829         assert(obj->tag == LDKEvent_DiscardFunding);
1830                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1831                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1832         return channel_id_arr;
1833 }
1834 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1835         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1836         assert(obj->tag == LDKEvent_DiscardFunding);
1837                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1838                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1839                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1840         return transaction_arr;
1841 }
1842 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1843         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1844         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1845                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1846                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1847         return payment_id_arr;
1848 }
1849 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1850         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1851         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1852                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1853                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1854         return payment_hash_arr;
1855 }
1856 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1857         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1858         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1859                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1860                         uint32_tArray path_arr = NULL;
1861                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1862                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1863                         for (size_t k = 0; k < path_var.datalen; k++) {
1864                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1865                                 uint32_t path_conv_10_ref = 0;
1866                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1867                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1868                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1869                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1870                                 path_arr_ptr[k] = path_conv_10_ref;
1871                         }
1872                         
1873         return path_arr;
1874 }
1875 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1876         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1877         assert(obj->tag == LDKEvent_OpenChannelRequest);
1878                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1879                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1880         return temporary_channel_id_arr;
1881 }
1882 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1883         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1884         assert(obj->tag == LDKEvent_OpenChannelRequest);
1885                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1886                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1887         return counterparty_node_id_arr;
1888 }
1889 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1890         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1891         assert(obj->tag == LDKEvent_OpenChannelRequest);
1892         return obj->open_channel_request.funding_satoshis;
1893 }
1894 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1895         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1896         assert(obj->tag == LDKEvent_OpenChannelRequest);
1897         return obj->open_channel_request.push_msat;
1898 }
1899 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1900         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1901         assert(obj->tag == LDKEvent_OpenChannelRequest);
1902                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1903                         uint32_t channel_type_ref = 0;
1904                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1905                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1906                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1907                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1908         return channel_type_ref;
1909 }
1910 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1911         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1912         switch(obj->tag) {
1913                 case LDKCOption_EventZ_Some: return 0;
1914                 case LDKCOption_EventZ_None: return 1;
1915                 default: abort();
1916         }
1917 }
1918 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1919         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1920         assert(obj->tag == LDKCOption_EventZ_Some);
1921                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1922         return some_ref;
1923 }
1924 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1925 CHECK(owner->result_ok);
1926         return COption_EventZ_clone(&*owner->contents.result);
1927 }
1928 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1929         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1930         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1931         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1932         uint32_t ret_ref = (uintptr_t)ret_copy;
1933         return ret_ref;
1934 }
1935
1936 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1937 CHECK(!owner->result_ok);
1938         return DecodeError_clone(&*owner->contents.err);
1939 }
1940 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1941         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1942         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1943         uint32_t ret_ref = 0;
1944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1947         ret_ref = (uintptr_t)ret_var.inner;
1948         if (ret_var.is_owned) {
1949                 ret_ref |= 1;
1950         }
1951         return ret_ref;
1952 }
1953
1954 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1955         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1956         switch(obj->tag) {
1957                 case LDKErrorAction_DisconnectPeer: return 0;
1958                 case LDKErrorAction_IgnoreError: return 1;
1959                 case LDKErrorAction_IgnoreAndLog: return 2;
1960                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1961                 case LDKErrorAction_SendErrorMessage: return 4;
1962                 case LDKErrorAction_SendWarningMessage: return 5;
1963                 default: abort();
1964         }
1965 }
1966 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1967         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1968         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1969                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1970                         uint32_t msg_ref = 0;
1971                         if ((uintptr_t)msg_var.inner > 4096) {
1972                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1973                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1974                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1975                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1976                         }
1977         return msg_ref;
1978 }
1979 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1980         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1981         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1982                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1983         return ignore_and_log_conv;
1984 }
1985 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1986         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1987         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1988                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1989                         uint32_t msg_ref = 0;
1990                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1991                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1992                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1993                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1994         return msg_ref;
1995 }
1996 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1997         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1998         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1999                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2000                         uint32_t msg_ref = 0;
2001                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2002                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2003                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2004                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2005         return msg_ref;
2006 }
2007 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2008         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2009         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2010                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2011         return log_level_conv;
2012 }
2013 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2014         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2015         switch(obj->tag) {
2016                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2017                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2018                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2019                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2020                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2021                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2022                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2023                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2024                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2025                 case LDKMessageSendEvent_SendShutdown: return 9;
2026                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2027                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2028                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2029                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2030                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2031                 case LDKMessageSendEvent_HandleError: return 15;
2032                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2033                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2034                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2035                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2036                 default: abort();
2037         }
2038 }
2039 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2040         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2041         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2042                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2043                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2044         return node_id_arr;
2045 }
2046 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2047         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2048         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2049                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2050                         uint32_t msg_ref = 0;
2051                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2052                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2053                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2054                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2055         return msg_ref;
2056 }
2057 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2058         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2059         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2060                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2061                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2062         return node_id_arr;
2063 }
2064 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2065         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2066         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2067                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2068                         uint32_t msg_ref = 0;
2069                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2070                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2071                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2072                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2073         return msg_ref;
2074 }
2075 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2076         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2077         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2078                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2079                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2080         return node_id_arr;
2081 }
2082 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2083         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2084         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2085                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2086                         uint32_t msg_ref = 0;
2087                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2090                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2091         return msg_ref;
2092 }
2093 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2094         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2095         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2096                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2097                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2098         return node_id_arr;
2099 }
2100 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2101         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2102         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2103                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2104                         uint32_t msg_ref = 0;
2105                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2106                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2107                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2108                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2109         return msg_ref;
2110 }
2111 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2112         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2113         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2114                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2115                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2116         return node_id_arr;
2117 }
2118 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2119         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2120         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2121                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2122                         uint32_t msg_ref = 0;
2123                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2124                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2126                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2127         return msg_ref;
2128 }
2129 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2130         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2131         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2132                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2133                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2134         return node_id_arr;
2135 }
2136 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2137         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2138         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2139                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2140                         uint32_t msg_ref = 0;
2141                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2144                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2145         return msg_ref;
2146 }
2147 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2148         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2149         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2150                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2151                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2152         return node_id_arr;
2153 }
2154 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2155         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2156         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2157                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2158                         uint32_t updates_ref = 0;
2159                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2160                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2161                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2162                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2163         return updates_ref;
2164 }
2165 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2166         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2167         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2168                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2169                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2170         return node_id_arr;
2171 }
2172 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2173         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2174         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2175                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2176                         uint32_t msg_ref = 0;
2177                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2178                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2179                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2180                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2181         return msg_ref;
2182 }
2183 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2184         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2185         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2186                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2187                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2188         return node_id_arr;
2189 }
2190 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2191         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2192         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2193                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2194                         uint32_t msg_ref = 0;
2195                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2196                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2197                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2198                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2199         return msg_ref;
2200 }
2201 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2202         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2203         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2204                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2205                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2206         return node_id_arr;
2207 }
2208 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2209         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2210         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2211                         LDKShutdown msg_var = obj->send_shutdown.msg;
2212                         uint32_t msg_ref = 0;
2213                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2214                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2216                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2217         return msg_ref;
2218 }
2219 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2221         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2222                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2223                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2224         return node_id_arr;
2225 }
2226 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2227         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2228         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2229                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2230                         uint32_t msg_ref = 0;
2231                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2232                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2233                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2234                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2235         return msg_ref;
2236 }
2237 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2238         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2239         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2240                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2241                         uint32_t msg_ref = 0;
2242                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2245                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2246         return msg_ref;
2247 }
2248 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2249         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2250         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2251                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2252                         uint32_t update_msg_ref = 0;
2253                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2254                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2256                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2257         return update_msg_ref;
2258 }
2259 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2260         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2261         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2262                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2263                         uint32_t msg_ref = 0;
2264                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2265                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2266                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2267                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2268         return msg_ref;
2269 }
2270 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2271         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2272         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2273                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2274                         uint32_t msg_ref = 0;
2275                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2276                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2277                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2278                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2279         return msg_ref;
2280 }
2281 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2282         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2283         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2284                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2285                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2286         return node_id_arr;
2287 }
2288 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2289         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2290         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2291                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2292                         uint32_t msg_ref = 0;
2293                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2294                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2296                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2297         return msg_ref;
2298 }
2299 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2300         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2301         assert(obj->tag == LDKMessageSendEvent_HandleError);
2302                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2303                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2304         return node_id_arr;
2305 }
2306 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2307         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2308         assert(obj->tag == LDKMessageSendEvent_HandleError);
2309                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2310         return action_ref;
2311 }
2312 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2313         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2314         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2315                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2316                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2317         return node_id_arr;
2318 }
2319 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2320         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2321         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2322                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2323                         uint32_t msg_ref = 0;
2324                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2325                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2326                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2327                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2328         return msg_ref;
2329 }
2330 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2331         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2332         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2333                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2334                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2335         return node_id_arr;
2336 }
2337 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2338         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2339         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2340                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2341                         uint32_t msg_ref = 0;
2342                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2343                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2344                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2345                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2346         return msg_ref;
2347 }
2348 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2349         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2350         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2351                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2352                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2353         return node_id_arr;
2354 }
2355 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2356         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2357         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2358                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2359                         uint32_t msg_ref = 0;
2360                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2363                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2364         return msg_ref;
2365 }
2366 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2367         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2368         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2369                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2370                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2371         return node_id_arr;
2372 }
2373 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2374         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2375         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2376                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2377                         uint32_t msg_ref = 0;
2378                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2379                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2380                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2381                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2382         return msg_ref;
2383 }
2384 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2385         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2386         for (size_t i = 0; i < ret.datalen; i++) {
2387                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2388         }
2389         return ret;
2390 }
2391 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2392 CHECK(owner->result_ok);
2393         return FixedPenaltyScorer_clone(&*owner->contents.result);
2394 }
2395 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2396         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2397         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2398         uint32_t ret_ref = 0;
2399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2402         ret_ref = (uintptr_t)ret_var.inner;
2403         if (ret_var.is_owned) {
2404                 ret_ref |= 1;
2405         }
2406         return ret_ref;
2407 }
2408
2409 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2410 CHECK(!owner->result_ok);
2411         return DecodeError_clone(&*owner->contents.err);
2412 }
2413 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2414         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2415         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2416         uint32_t ret_ref = 0;
2417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2420         ret_ref = (uintptr_t)ret_var.inner;
2421         if (ret_var.is_owned) {
2422                 ret_ref |= 1;
2423         }
2424         return ret_ref;
2425 }
2426
2427 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2428 CHECK(owner->result_ok);
2429         return ScoringParameters_clone(&*owner->contents.result);
2430 }
2431 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2432         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2433         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2434         uint32_t ret_ref = 0;
2435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2438         ret_ref = (uintptr_t)ret_var.inner;
2439         if (ret_var.is_owned) {
2440                 ret_ref |= 1;
2441         }
2442         return ret_ref;
2443 }
2444
2445 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2446 CHECK(!owner->result_ok);
2447         return DecodeError_clone(&*owner->contents.err);
2448 }
2449 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2450         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2451         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2452         uint32_t ret_ref = 0;
2453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2456         ret_ref = (uintptr_t)ret_var.inner;
2457         if (ret_var.is_owned) {
2458                 ret_ref |= 1;
2459         }
2460         return ret_ref;
2461 }
2462
2463 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2464 CHECK(owner->result_ok);
2465         return &*owner->contents.result;
2466 }
2467 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2468         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2469         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2470         uint32_t ret_ref = 0;
2471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2474         ret_ref = (uintptr_t)ret_var.inner & ~1;
2475         return ret_ref;
2476 }
2477
2478 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2479 CHECK(!owner->result_ok);
2480         return DecodeError_clone(&*owner->contents.err);
2481 }
2482 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2483         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2484         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2485         uint32_t ret_ref = 0;
2486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2489         ret_ref = (uintptr_t)ret_var.inner;
2490         if (ret_var.is_owned) {
2491                 ret_ref |= 1;
2492         }
2493         return ret_ref;
2494 }
2495
2496 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2497 CHECK(owner->result_ok);
2498         return &*owner->contents.result;
2499 }
2500 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2501         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2502         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2503         uint32_t ret_ref = 0;
2504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2507         ret_ref = (uintptr_t)ret_var.inner & ~1;
2508         return ret_ref;
2509 }
2510
2511 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2512 CHECK(!owner->result_ok);
2513         return DecodeError_clone(&*owner->contents.err);
2514 }
2515 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2516         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2517         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2518         uint32_t ret_ref = 0;
2519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2522         ret_ref = (uintptr_t)ret_var.inner;
2523         if (ret_var.is_owned) {
2524                 ret_ref |= 1;
2525         }
2526         return ret_ref;
2527 }
2528
2529 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2530 CHECK(owner->result_ok);
2531         return InitFeatures_clone(&*owner->contents.result);
2532 }
2533 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2534         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2535         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2536         uint32_t ret_ref = 0;
2537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2540         ret_ref = (uintptr_t)ret_var.inner;
2541         if (ret_var.is_owned) {
2542                 ret_ref |= 1;
2543         }
2544         return ret_ref;
2545 }
2546
2547 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2548 CHECK(!owner->result_ok);
2549         return DecodeError_clone(&*owner->contents.err);
2550 }
2551 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2552         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2553         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2554         uint32_t ret_ref = 0;
2555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2558         ret_ref = (uintptr_t)ret_var.inner;
2559         if (ret_var.is_owned) {
2560                 ret_ref |= 1;
2561         }
2562         return ret_ref;
2563 }
2564
2565 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2566 CHECK(owner->result_ok);
2567         return ChannelFeatures_clone(&*owner->contents.result);
2568 }
2569 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2570         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2571         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2572         uint32_t ret_ref = 0;
2573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2576         ret_ref = (uintptr_t)ret_var.inner;
2577         if (ret_var.is_owned) {
2578                 ret_ref |= 1;
2579         }
2580         return ret_ref;
2581 }
2582
2583 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2584 CHECK(!owner->result_ok);
2585         return DecodeError_clone(&*owner->contents.err);
2586 }
2587 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2588         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2589         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2590         uint32_t ret_ref = 0;
2591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2594         ret_ref = (uintptr_t)ret_var.inner;
2595         if (ret_var.is_owned) {
2596                 ret_ref |= 1;
2597         }
2598         return ret_ref;
2599 }
2600
2601 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2602 CHECK(owner->result_ok);
2603         return NodeFeatures_clone(&*owner->contents.result);
2604 }
2605 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2606         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2607         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2608         uint32_t ret_ref = 0;
2609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2612         ret_ref = (uintptr_t)ret_var.inner;
2613         if (ret_var.is_owned) {
2614                 ret_ref |= 1;
2615         }
2616         return ret_ref;
2617 }
2618
2619 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2620 CHECK(!owner->result_ok);
2621         return DecodeError_clone(&*owner->contents.err);
2622 }
2623 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2624         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2625         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2626         uint32_t ret_ref = 0;
2627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2630         ret_ref = (uintptr_t)ret_var.inner;
2631         if (ret_var.is_owned) {
2632                 ret_ref |= 1;
2633         }
2634         return ret_ref;
2635 }
2636
2637 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2638 CHECK(owner->result_ok);
2639         return InvoiceFeatures_clone(&*owner->contents.result);
2640 }
2641 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2642         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2643         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2644         uint32_t ret_ref = 0;
2645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2648         ret_ref = (uintptr_t)ret_var.inner;
2649         if (ret_var.is_owned) {
2650                 ret_ref |= 1;
2651         }
2652         return ret_ref;
2653 }
2654
2655 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2656 CHECK(!owner->result_ok);
2657         return DecodeError_clone(&*owner->contents.err);
2658 }
2659 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2660         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2661         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2662         uint32_t ret_ref = 0;
2663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2666         ret_ref = (uintptr_t)ret_var.inner;
2667         if (ret_var.is_owned) {
2668                 ret_ref |= 1;
2669         }
2670         return ret_ref;
2671 }
2672
2673 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2674 CHECK(owner->result_ok);
2675         return ChannelTypeFeatures_clone(&*owner->contents.result);
2676 }
2677 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2678         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2679         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2680         uint32_t ret_ref = 0;
2681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2684         ret_ref = (uintptr_t)ret_var.inner;
2685         if (ret_var.is_owned) {
2686                 ret_ref |= 1;
2687         }
2688         return ret_ref;
2689 }
2690
2691 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2692 CHECK(!owner->result_ok);
2693         return DecodeError_clone(&*owner->contents.err);
2694 }
2695 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2696         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2697         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2698         uint32_t ret_ref = 0;
2699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2702         ret_ref = (uintptr_t)ret_var.inner;
2703         if (ret_var.is_owned) {
2704                 ret_ref |= 1;
2705         }
2706         return ret_ref;
2707 }
2708
2709 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2710 CHECK(owner->result_ok);
2711         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2712 }
2713 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2714         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2715         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2716         uint32_t ret_ref = 0;
2717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2720         ret_ref = (uintptr_t)ret_var.inner;
2721         if (ret_var.is_owned) {
2722                 ret_ref |= 1;
2723         }
2724         return ret_ref;
2725 }
2726
2727 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2728 CHECK(!owner->result_ok);
2729         return DecodeError_clone(&*owner->contents.err);
2730 }
2731 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2732         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2733         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2734         uint32_t ret_ref = 0;
2735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2738         ret_ref = (uintptr_t)ret_var.inner;
2739         if (ret_var.is_owned) {
2740                 ret_ref |= 1;
2741         }
2742         return ret_ref;
2743 }
2744
2745 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2746 CHECK(owner->result_ok);
2747         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2748 }
2749 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2750         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2751         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2752         uint32_t ret_ref = 0;
2753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2756         ret_ref = (uintptr_t)ret_var.inner;
2757         if (ret_var.is_owned) {
2758                 ret_ref |= 1;
2759         }
2760         return ret_ref;
2761 }
2762
2763 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2764 CHECK(!owner->result_ok);
2765         return DecodeError_clone(&*owner->contents.err);
2766 }
2767 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2768         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2769         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2770         uint32_t ret_ref = 0;
2771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2774         ret_ref = (uintptr_t)ret_var.inner;
2775         if (ret_var.is_owned) {
2776                 ret_ref |= 1;
2777         }
2778         return ret_ref;
2779 }
2780
2781 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2782 CHECK(owner->result_ok);
2783         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2784 }
2785 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2786         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2787         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2788         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2789         uint32_t ret_ref = (uintptr_t)ret_copy;
2790         return ret_ref;
2791 }
2792
2793 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2794 CHECK(!owner->result_ok);
2795         return DecodeError_clone(&*owner->contents.err);
2796 }
2797 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2798         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2799         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2800         uint32_t ret_ref = 0;
2801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2804         ret_ref = (uintptr_t)ret_var.inner;
2805         if (ret_var.is_owned) {
2806                 ret_ref |= 1;
2807         }
2808         return ret_ref;
2809 }
2810
2811 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2812         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2813         for (size_t i = 0; i < ret.datalen; i++) {
2814                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2815         }
2816         return ret;
2817 }
2818 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2819         return owner->a;
2820 }
2821 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2822         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2823         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2824         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2825         return ret_arr;
2826 }
2827
2828 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2829         return owner->b;
2830 }
2831 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2832         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2833         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2834         ptrArray ret_arr = NULL;
2835         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2836         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2837         for (size_t m = 0; m < ret_var.datalen; m++) {
2838                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2839                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2840                 ret_arr_ptr[m] = ret_conv_12_arr;
2841         }
2842         
2843         return ret_arr;
2844 }
2845
2846 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2847 CHECK(owner->result_ok);
2848         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2849 }
2850 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2851         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2852         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2853         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2854         return ((uint32_t)ret_conv);
2855 }
2856
2857 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2858 CHECK(!owner->result_ok);
2859         return *owner->contents.err;
2860 }
2861 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2862         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2863         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2864 }
2865
2866 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2867 CHECK(owner->result_ok);
2868         return *owner->contents.result;
2869 }
2870 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2871         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2872         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2873         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2874         return ret_arr;
2875 }
2876
2877 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2878 CHECK(!owner->result_ok);
2879         return *owner->contents.err;
2880 }
2881 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2882         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2883         CResult_SignatureNoneZ_get_err(owner_conv);
2884 }
2885
2886 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2887         return owner->a;
2888 }
2889 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2890         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2891         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2892         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2893         return ret_arr;
2894 }
2895
2896 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2897         return owner->b;
2898 }
2899 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2900         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2901         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2902         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2903         return ret_arr;
2904 }
2905
2906 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2907 CHECK(owner->result_ok);
2908         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2909 }
2910 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2911         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2912         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2913         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2914         return ((uint32_t)ret_conv);
2915 }
2916
2917 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2918 CHECK(!owner->result_ok);
2919         return *owner->contents.err;
2920 }
2921 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2922         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2923         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2924 }
2925
2926 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2927 CHECK(owner->result_ok);
2928         return *owner->contents.result;
2929 }
2930 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2931         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2932         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2933         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2934         return ret_arr;
2935 }
2936
2937 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2938 CHECK(!owner->result_ok);
2939         return *owner->contents.err;
2940 }
2941 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2942         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2943         CResult_SecretKeyNoneZ_get_err(owner_conv);
2944 }
2945
2946 typedef struct LDKBaseSign_JCalls {
2947         atomic_size_t refcnt;
2948         uint32_t instance_ptr;
2949 } LDKBaseSign_JCalls;
2950 static void LDKBaseSign_JCalls_free(void* this_arg) {
2951         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2952         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2953                 FREE(j_calls);
2954         }
2955 }
2956 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2957         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2958         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx);
2959         LDKPublicKey ret_ref;
2960         CHECK(ret->arr_len == 33);
2961         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2962         return ret_ref;
2963 }
2964 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2965         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2966         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx);
2967         LDKThirtyTwoBytes ret_ref;
2968         CHECK(ret->arr_len == 32);
2969         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2970         return ret_ref;
2971 }
2972 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2973         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2974         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2975         uint32_t holder_tx_ref = 0;
2976         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
2977         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2978         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2979         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2980         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2981         if (holder_tx_var.is_owned) {
2982                 holder_tx_ref |= 1;
2983         }
2984         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2985         ptrArray preimages_arr = NULL;
2986         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2987         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2988         for (size_t m = 0; m < preimages_var.datalen; m++) {
2989                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2990                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2991                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2992         }
2993         
2994         FREE(preimages_var.data);
2995         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
2996         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2997         CHECK_ACCESS(ret_ptr);
2998         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2999         FREE((void*)ret);
3000         return ret_conv;
3001 }
3002 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3003         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3004         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
3005         LDKThirtyTwoBytes ret_ref;
3006         CHECK(ret->arr_len == 32);
3007         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3008         return ret_ref;
3009 }
3010 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3011         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3012         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3013         uint32_t commitment_tx_ref = 0;
3014         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3015         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3016         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3017         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3018         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3019         if (commitment_tx_var.is_owned) {
3020                 commitment_tx_ref |= 1;
3021         }
3022         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3023         ptrArray preimages_arr = NULL;
3024         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3025         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3026         for (size_t m = 0; m < preimages_var.datalen; m++) {
3027                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3028                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3029                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3030         }
3031         
3032         FREE(preimages_var.data);
3033         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3034         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3035         CHECK_ACCESS(ret_ptr);
3036         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3037         FREE((void*)ret);
3038         return ret_conv;
3039 }
3040 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3041         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3042         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3043         memcpy(secret_arr->elems, *secret, 32);
3044         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx, (uint32_t)secret_arr);
3045         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3046         CHECK_ACCESS(ret_ptr);
3047         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3048         FREE((void*)ret);
3049         return ret_conv;
3050 }
3051 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3052         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3053         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3054         uint32_t commitment_tx_ref = 0;
3055         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3056         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3057         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3058         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3059         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3060         if (commitment_tx_var.is_owned) {
3061                 commitment_tx_ref |= 1;
3062         }
3063         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3064         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3065         CHECK_ACCESS(ret_ptr);
3066         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3067         FREE((void*)ret);
3068         return ret_conv;
3069 }
3070 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]) {
3071         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3072         LDKTransaction justice_tx_var = justice_tx;
3073         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3074         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3075         Transaction_free(justice_tx_var);
3076         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3077         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3078         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 7, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr);
3079         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3080         CHECK_ACCESS(ret_ptr);
3081         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3082         FREE((void*)ret);
3083         return ret_conv;
3084 }
3085 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) {
3086         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3087         LDKTransaction justice_tx_var = justice_tx;
3088         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3089         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3090         Transaction_free(justice_tx_var);
3091         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3092         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3093         LDKHTLCOutputInCommitment htlc_var = *htlc;
3094         uint32_t htlc_ref = 0;
3095         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3096         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3097         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3098         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3099         htlc_ref = (uintptr_t)htlc_var.inner;
3100         if (htlc_var.is_owned) {
3101                 htlc_ref |= 1;
3102         }
3103         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 8, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
3104         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3105         CHECK_ACCESS(ret_ptr);
3106         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3107         FREE((void*)ret);
3108         return ret_conv;
3109 }
3110 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) {
3111         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3112         LDKTransaction htlc_tx_var = htlc_tx;
3113         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3114         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3115         Transaction_free(htlc_tx_var);
3116         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3117         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3118         LDKHTLCOutputInCommitment htlc_var = *htlc;
3119         uint32_t htlc_ref = 0;
3120         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3121         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3122         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3123         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3124         htlc_ref = (uintptr_t)htlc_var.inner;
3125         if (htlc_var.is_owned) {
3126                 htlc_ref |= 1;
3127         }
3128         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 9, (uint32_t)htlc_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
3129         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3130         CHECK_ACCESS(ret_ptr);
3131         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3132         FREE((void*)ret);
3133         return ret_conv;
3134 }
3135 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3136         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3137         LDKClosingTransaction closing_tx_var = *closing_tx;
3138         uint32_t closing_tx_ref = 0;
3139         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3140         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3141         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3142         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3143         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3144         if (closing_tx_var.is_owned) {
3145                 closing_tx_ref |= 1;
3146         }
3147         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3148         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3149         CHECK_ACCESS(ret_ptr);
3150         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3151         FREE((void*)ret);
3152         return ret_conv;
3153 }
3154 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3155         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3156         LDKUnsignedChannelAnnouncement msg_var = *msg;
3157         uint32_t msg_ref = 0;
3158         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3159         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3160         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3161         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3162         msg_ref = (uintptr_t)msg_var.inner;
3163         if (msg_var.is_owned) {
3164                 msg_ref |= 1;
3165         }
3166         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3167         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3168         CHECK_ACCESS(ret_ptr);
3169         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3170         FREE((void*)ret);
3171         return ret_conv;
3172 }
3173 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3174         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3175         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3176         uint32_t channel_parameters_ref = 0;
3177         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3178         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3179         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3180         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3181         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3182         if (channel_parameters_var.is_owned) {
3183                 channel_parameters_ref |= 1;
3184         }
3185         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3186 }
3187 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3188         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3189         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3190 }
3191 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3192         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3193         atomic_init(&calls->refcnt, 1);
3194         calls->instance_ptr = o;
3195
3196         LDKChannelPublicKeys pubkeys_conv;
3197         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3198         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3199         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3200
3201         LDKBaseSign ret = {
3202                 .this_arg = (void*) calls,
3203                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3204                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3205                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3206                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3207                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3208                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3209                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3210                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3211                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3212                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3213                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3214                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3215                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3216                 .free = LDKBaseSign_JCalls_free,
3217                 .pubkeys = pubkeys_conv,
3218                 .set_pubkeys = NULL,
3219         };
3220         return ret;
3221 }
3222 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3223         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3224         *res_ptr = LDKBaseSign_init(o, pubkeys);
3225         return (long)res_ptr;
3226 }
3227 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3228         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3229         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3230         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3231         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3232         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3233         return ret_arr;
3234 }
3235
3236 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3237         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3238         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3239         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3240         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3241         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3242         return ret_arr;
3243 }
3244
3245 uint32_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx, ptrArray preimages) {
3246         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3247         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3248         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3249         LDKHolderCommitmentTransaction holder_tx_conv;
3250         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3251         holder_tx_conv.is_owned = false;
3252         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3253         LDKCVec_PaymentPreimageZ preimages_constr;
3254         preimages_constr.datalen = preimages->arr_len;
3255         if (preimages_constr.datalen > 0)
3256                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3257         else
3258                 preimages_constr.data = NULL;
3259         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3260         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3261                 int8_tArray preimages_conv_12 = preimages_vals[m];
3262                 LDKThirtyTwoBytes preimages_conv_12_ref;
3263                 CHECK(preimages_conv_12->arr_len == 32);
3264                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3265                 preimages_constr.data[m] = preimages_conv_12_ref;
3266         }
3267         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3268         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3269         return (uint32_t)ret_conv;
3270 }
3271
3272 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3273         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3274         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3275         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3276         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3277         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3278         return ret_arr;
3279 }
3280
3281 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx, ptrArray preimages) {
3282         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3283         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3284         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3285         LDKCommitmentTransaction commitment_tx_conv;
3286         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3287         commitment_tx_conv.is_owned = false;
3288         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3289         LDKCVec_PaymentPreimageZ preimages_constr;
3290         preimages_constr.datalen = preimages->arr_len;
3291         if (preimages_constr.datalen > 0)
3292                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3293         else
3294                 preimages_constr.data = NULL;
3295         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3296         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3297                 int8_tArray preimages_conv_12 = preimages_vals[m];
3298                 LDKThirtyTwoBytes preimages_conv_12_ref;
3299                 CHECK(preimages_conv_12->arr_len == 32);
3300                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3301                 preimages_constr.data[m] = preimages_conv_12_ref;
3302         }
3303         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3304         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3305         return (uint32_t)ret_conv;
3306 }
3307
3308 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) {
3309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3311         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3312         unsigned char secret_arr[32];
3313         CHECK(secret->arr_len == 32);
3314         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3315         unsigned char (*secret_ref)[32] = &secret_arr;
3316         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3317         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3318         return (uint32_t)ret_conv;
3319 }
3320
3321 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) {
3322         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3324         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3325         LDKHolderCommitmentTransaction commitment_tx_conv;
3326         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3327         commitment_tx_conv.is_owned = false;
3328         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3329         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3330         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3331         return (uint32_t)ret_conv;
3332 }
3333
3334 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_output"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key) {
3335         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3336         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3337         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3338         LDKTransaction justice_tx_ref;
3339         justice_tx_ref.datalen = justice_tx->arr_len;
3340         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3341         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3342         justice_tx_ref.data_is_owned = true;
3343         unsigned char per_commitment_key_arr[32];
3344         CHECK(per_commitment_key->arr_len == 32);
3345         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3346         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3347         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3348         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3349         return (uint32_t)ret_conv;
3350 }
3351
3352 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_htlc"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
3353         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3355         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3356         LDKTransaction justice_tx_ref;
3357         justice_tx_ref.datalen = justice_tx->arr_len;
3358         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3359         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3360         justice_tx_ref.data_is_owned = true;
3361         unsigned char per_commitment_key_arr[32];
3362         CHECK(per_commitment_key->arr_len == 32);
3363         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3364         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3365         LDKHTLCOutputInCommitment htlc_conv;
3366         htlc_conv.inner = (void*)(htlc & (~1));
3367         htlc_conv.is_owned = false;
3368         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3369         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3370         *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);
3371         return (uint32_t)ret_conv;
3372 }
3373
3374 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_htlc_transaction"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
3375         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3376         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3377         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3378         LDKTransaction htlc_tx_ref;
3379         htlc_tx_ref.datalen = htlc_tx->arr_len;
3380         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3381         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3382         htlc_tx_ref.data_is_owned = true;
3383         LDKPublicKey per_commitment_point_ref;
3384         CHECK(per_commitment_point->arr_len == 33);
3385         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3386         LDKHTLCOutputInCommitment htlc_conv;
3387         htlc_conv.inner = (void*)(htlc & (~1));
3388         htlc_conv.is_owned = false;
3389         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3390         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3391         *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);
3392         return (uint32_t)ret_conv;
3393 }
3394
3395 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3396         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3397         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3398         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3399         LDKClosingTransaction closing_tx_conv;
3400         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3401         closing_tx_conv.is_owned = false;
3402         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3403         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3404         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3405         return (uint32_t)ret_conv;
3406 }
3407
3408 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3409         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3410         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3411         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3412         LDKUnsignedChannelAnnouncement msg_conv;
3413         msg_conv.inner = (void*)(msg & (~1));
3414         msg_conv.is_owned = false;
3415         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3416         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3417         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3418         return (uint32_t)ret_conv;
3419 }
3420
3421 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3422         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3423         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3424         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3425         LDKChannelTransactionParameters channel_parameters_conv;
3426         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3427         channel_parameters_conv.is_owned = false;
3428         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3429         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3430 }
3431
3432 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3433         if (this_arg->set_pubkeys != NULL)
3434                 this_arg->set_pubkeys(this_arg);
3435         return this_arg->pubkeys;
3436 }
3437 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3438         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3439         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3440         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3441         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3442         uint32_t ret_ref = 0;
3443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3446         ret_ref = (uintptr_t)ret_var.inner;
3447         if (ret_var.is_owned) {
3448                 ret_ref |= 1;
3449         }
3450         return ret_ref;
3451 }
3452
3453 typedef struct LDKSign_JCalls {
3454         atomic_size_t refcnt;
3455         uint32_t instance_ptr;
3456         LDKBaseSign_JCalls* BaseSign;
3457 } LDKSign_JCalls;
3458 static void LDKSign_JCalls_free(void* this_arg) {
3459         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3460         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3461                 FREE(j_calls);
3462         }
3463 }
3464 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3465         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3466         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3467         LDKCVec_u8Z ret_ref;
3468         ret_ref.datalen = ret->arr_len;
3469         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3470         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3471         return ret_ref;
3472 }
3473 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3474         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3475         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3476         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3477 }
3478 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3479         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3480         atomic_init(&calls->refcnt, 1);
3481         calls->instance_ptr = o;
3482
3483         LDKChannelPublicKeys pubkeys_conv;
3484         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3485         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3486         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3487
3488         LDKSign ret = {
3489                 .this_arg = (void*) calls,
3490                 .write = write_LDKSign_jcall,
3491                 .cloned = LDKSign_JCalls_cloned,
3492                 .free = LDKSign_JCalls_free,
3493                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3494         };
3495         calls->BaseSign = ret.BaseSign.this_arg;
3496         return ret;
3497 }
3498 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3499         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3500         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3501         return (long)res_ptr;
3502 }
3503 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3506         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3507         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3508         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3509         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3510         CVec_u8Z_free(ret_var);
3511         return ret_arr;
3512 }
3513
3514 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3515 CHECK(owner->result_ok);
3516         return Sign_clone(&*owner->contents.result);
3517 }
3518 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3519         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3520         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3521         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3522         return (uint32_t)ret_ret;
3523 }
3524
3525 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3526 CHECK(!owner->result_ok);
3527         return DecodeError_clone(&*owner->contents.err);
3528 }
3529 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3530         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3531         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3532         uint32_t ret_ref = 0;
3533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3536         ret_ref = (uintptr_t)ret_var.inner;
3537         if (ret_var.is_owned) {
3538                 ret_ref |= 1;
3539         }
3540         return ret_ref;
3541 }
3542
3543 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3544 CHECK(owner->result_ok);
3545         return *owner->contents.result;
3546 }
3547 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3548         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3549         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3550         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3551         return ret_arr;
3552 }
3553
3554 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3555 CHECK(!owner->result_ok);
3556         return *owner->contents.err;
3557 }
3558 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3559         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3560         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3561 }
3562
3563 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3564         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3565         for (size_t i = 0; i < ret.datalen; i++) {
3566                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3567         }
3568         return ret;
3569 }
3570 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3571 CHECK(owner->result_ok);
3572         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3573 }
3574 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3575         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3576         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3577         ptrArray ret_arr = NULL;
3578         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3579         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3580         for (size_t m = 0; m < ret_var.datalen; m++) {
3581                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3582                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3583                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3584                 CVec_u8Z_free(ret_conv_12_var);
3585                 ret_arr_ptr[m] = ret_conv_12_arr;
3586         }
3587         
3588         FREE(ret_var.data);
3589         return ret_arr;
3590 }
3591
3592 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3593 CHECK(!owner->result_ok);
3594         return *owner->contents.err;
3595 }
3596 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3597         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3598         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3599 }
3600
3601 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3602 CHECK(owner->result_ok);
3603         return InMemorySigner_clone(&*owner->contents.result);
3604 }
3605 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3606         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3607         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3608         uint32_t ret_ref = 0;
3609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3612         ret_ref = (uintptr_t)ret_var.inner;
3613         if (ret_var.is_owned) {
3614                 ret_ref |= 1;
3615         }
3616         return ret_ref;
3617 }
3618
3619 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3620 CHECK(!owner->result_ok);
3621         return DecodeError_clone(&*owner->contents.err);
3622 }
3623 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3624         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3625         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3626         uint32_t ret_ref = 0;
3627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3630         ret_ref = (uintptr_t)ret_var.inner;
3631         if (ret_var.is_owned) {
3632                 ret_ref |= 1;
3633         }
3634         return ret_ref;
3635 }
3636
3637 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3638         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3639         for (size_t i = 0; i < ret.datalen; i++) {
3640                 ret.data[i] = TxOut_clone(&orig->data[i]);
3641         }
3642         return ret;
3643 }
3644 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3645 CHECK(owner->result_ok);
3646         return *owner->contents.result;
3647 }
3648 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3649         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3650         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3653         return ret_arr;
3654 }
3655
3656 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3657 CHECK(!owner->result_ok);
3658         return *owner->contents.err;
3659 }
3660 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3661         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3662         CResult_TransactionNoneZ_get_err(owner_conv);
3663 }
3664
3665 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3666         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3667         switch(obj->tag) {
3668                 case LDKCOption_u16Z_Some: return 0;
3669                 case LDKCOption_u16Z_None: return 1;
3670                 default: abort();
3671         }
3672 }
3673 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3674         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3675         assert(obj->tag == LDKCOption_u16Z_Some);
3676         return obj->some;
3677 }
3678 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3679         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3680         switch(obj->tag) {
3681                 case LDKAPIError_APIMisuseError: return 0;
3682                 case LDKAPIError_FeeRateTooHigh: return 1;
3683                 case LDKAPIError_RouteError: return 2;
3684                 case LDKAPIError_ChannelUnavailable: return 3;
3685                 case LDKAPIError_MonitorUpdateFailed: return 4;
3686                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3687                 default: abort();
3688         }
3689 }
3690 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3691         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3692         assert(obj->tag == LDKAPIError_APIMisuseError);
3693                         LDKStr err_str = obj->api_misuse_error.err;
3694                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3695         return err_conv;
3696 }
3697 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3698         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3699         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3700                         LDKStr err_str = obj->fee_rate_too_high.err;
3701                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3702         return err_conv;
3703 }
3704 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3705         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3706         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3707         return obj->fee_rate_too_high.feerate;
3708 }
3709 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3710         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3711         assert(obj->tag == LDKAPIError_RouteError);
3712                         LDKStr err_str = obj->route_error.err;
3713                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3714         return err_conv;
3715 }
3716 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3717         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3718         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3719                         LDKStr err_str = obj->channel_unavailable.err;
3720                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3721         return err_conv;
3722 }
3723 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3724         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3725         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3726                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3727                         uint32_t script_ref = 0;
3728                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3729                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3730                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3731                         script_ref = (uintptr_t)script_var.inner & ~1;
3732         return script_ref;
3733 }
3734 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3735 CHECK(owner->result_ok);
3736         return *owner->contents.result;
3737 }
3738 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3739         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3740         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3741 }
3742
3743 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3744 CHECK(!owner->result_ok);
3745         return APIError_clone(&*owner->contents.err);
3746 }
3747 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3748         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3749         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3750         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3751         uint32_t ret_ref = (uintptr_t)ret_copy;
3752         return ret_ref;
3753 }
3754
3755 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3756         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3757         for (size_t i = 0; i < ret.datalen; i++) {
3758                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3759         }
3760         return ret;
3761 }
3762 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3763         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3764         for (size_t i = 0; i < ret.datalen; i++) {
3765                 ret.data[i] = APIError_clone(&orig->data[i]);
3766         }
3767         return ret;
3768 }
3769 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3770 CHECK(owner->result_ok);
3771         return ThirtyTwoBytes_clone(&*owner->contents.result);
3772 }
3773 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3774         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3775         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3776         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3777         return ret_arr;
3778 }
3779
3780 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3781 CHECK(!owner->result_ok);
3782         return APIError_clone(&*owner->contents.err);
3783 }
3784 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3785         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3786         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3787         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3788         uint32_t ret_ref = (uintptr_t)ret_copy;
3789         return ret_ref;
3790 }
3791
3792 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3793         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3794         switch(obj->tag) {
3795                 case LDKPaymentSendFailure_ParameterError: return 0;
3796                 case LDKPaymentSendFailure_PathParameterError: return 1;
3797                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3798                 case LDKPaymentSendFailure_PartialFailure: return 3;
3799                 default: abort();
3800         }
3801 }
3802 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3803         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3804         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3805                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3806         return parameter_error_ref;
3807 }
3808 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3809         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3810         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3811                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3812                         uint32_tArray path_parameter_error_arr = NULL;
3813                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3814                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3815                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3816                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3817                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3818                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3819                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3820                         }
3821                         
3822         return path_parameter_error_arr;
3823 }
3824 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3825         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3826         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3827                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3828                         uint32_tArray all_failed_retry_safe_arr = NULL;
3829                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3830                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3831                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3832                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3833                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3834                         }
3835                         
3836         return all_failed_retry_safe_arr;
3837 }
3838 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3839         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3840         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3841                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3842                         uint32_tArray results_arr = NULL;
3843                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3844                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3845                         for (size_t w = 0; w < results_var.datalen; w++) {
3846                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3847                                 *results_conv_22_conv = results_var.data[w];
3848                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3849                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3850                         }
3851                         
3852         return results_arr;
3853 }
3854 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3855         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3856         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3857                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3858                         uint32_t failed_paths_retry_ref = 0;
3859                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3860                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3861                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3862                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3863                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3864                         }
3865         return failed_paths_retry_ref;
3866 }
3867 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3868         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3869         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3870                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3871                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3872         return payment_id_arr;
3873 }
3874 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3875 CHECK(owner->result_ok);
3876         return ThirtyTwoBytes_clone(&*owner->contents.result);
3877 }
3878 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3879         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3880         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3881         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3882         return ret_arr;
3883 }
3884
3885 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3886 CHECK(!owner->result_ok);
3887         return PaymentSendFailure_clone(&*owner->contents.err);
3888 }
3889 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3890         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3891         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3892         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3893         uint32_t ret_ref = (uintptr_t)ret_copy;
3894         return ret_ref;
3895 }
3896
3897 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3898 CHECK(owner->result_ok);
3899         return *owner->contents.result;
3900 }
3901 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3902         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3903         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3904 }
3905
3906 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3907 CHECK(!owner->result_ok);
3908         return PaymentSendFailure_clone(&*owner->contents.err);
3909 }
3910 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3911         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3912         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3913         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3914         uint32_t ret_ref = (uintptr_t)ret_copy;
3915         return ret_ref;
3916 }
3917
3918 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3919         return ThirtyTwoBytes_clone(&owner->a);
3920 }
3921 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3922         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3923         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3924         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3925         return ret_arr;
3926 }
3927
3928 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3929         return ThirtyTwoBytes_clone(&owner->b);
3930 }
3931 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3932         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3933         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3934         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3935         return ret_arr;
3936 }
3937
3938 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3939 CHECK(owner->result_ok);
3940         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3941 }
3942 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3943         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3944         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3945         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3946         return ((uint32_t)ret_conv);
3947 }
3948
3949 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3950 CHECK(!owner->result_ok);
3951         return PaymentSendFailure_clone(&*owner->contents.err);
3952 }
3953 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3954         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3955         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3956         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3957         uint32_t ret_ref = (uintptr_t)ret_copy;
3958         return ret_ref;
3959 }
3960
3961 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3962         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3963         switch(obj->tag) {
3964                 case LDKNetAddress_IPv4: return 0;
3965                 case LDKNetAddress_IPv6: return 1;
3966                 case LDKNetAddress_OnionV2: return 2;
3967                 case LDKNetAddress_OnionV3: return 3;
3968                 default: abort();
3969         }
3970 }
3971 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3972         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3973         assert(obj->tag == LDKNetAddress_IPv4);
3974                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3975                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3976         return addr_arr;
3977 }
3978 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3979         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3980         assert(obj->tag == LDKNetAddress_IPv4);
3981         return obj->i_pv4.port;
3982 }
3983 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3984         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3985         assert(obj->tag == LDKNetAddress_IPv6);
3986                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3987                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3988         return addr_arr;
3989 }
3990 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3991         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3992         assert(obj->tag == LDKNetAddress_IPv6);
3993         return obj->i_pv6.port;
3994 }
3995 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3996         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3997         assert(obj->tag == LDKNetAddress_OnionV2);
3998                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3999                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4000         return onion_v2_arr;
4001 }
4002 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
4003         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4004         assert(obj->tag == LDKNetAddress_OnionV3);
4005                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4006                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4007         return ed25519_pubkey_arr;
4008 }
4009 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
4010         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4011         assert(obj->tag == LDKNetAddress_OnionV3);
4012         return obj->onion_v3.checksum;
4013 }
4014 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
4015         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4016         assert(obj->tag == LDKNetAddress_OnionV3);
4017         return obj->onion_v3.version;
4018 }
4019 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
4020         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4021         assert(obj->tag == LDKNetAddress_OnionV3);
4022         return obj->onion_v3.port;
4023 }
4024 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4025         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4026         for (size_t i = 0; i < ret.datalen; i++) {
4027                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4028         }
4029         return ret;
4030 }
4031 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4032         return ThirtyTwoBytes_clone(&owner->a);
4033 }
4034 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4035         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4036         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4037         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4038         return ret_arr;
4039 }
4040
4041 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4042         return ThirtyTwoBytes_clone(&owner->b);
4043 }
4044 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4045         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4046         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4047         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4048         return ret_arr;
4049 }
4050
4051 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4052 CHECK(owner->result_ok);
4053         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4054 }
4055 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4056         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4057         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4058         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4059         return ((uint32_t)ret_conv);
4060 }
4061
4062 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4063 CHECK(!owner->result_ok);
4064         return *owner->contents.err;
4065 }
4066 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4067         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4068         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4069 }
4070
4071 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4072 CHECK(owner->result_ok);
4073         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4074 }
4075 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4076         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4077         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4078         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4079         return ((uint32_t)ret_conv);
4080 }
4081
4082 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4083 CHECK(!owner->result_ok);
4084         return APIError_clone(&*owner->contents.err);
4085 }
4086 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4087         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4088         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4089         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4090         uint32_t ret_ref = (uintptr_t)ret_copy;
4091         return ret_ref;
4092 }
4093
4094 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4095 CHECK(owner->result_ok);
4096         return ThirtyTwoBytes_clone(&*owner->contents.result);
4097 }
4098 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4099         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4100         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4101         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4102         return ret_arr;
4103 }
4104
4105 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4106 CHECK(!owner->result_ok);
4107         return *owner->contents.err;
4108 }
4109 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4110         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4111         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4112 }
4113
4114 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4115 CHECK(owner->result_ok);
4116         return ThirtyTwoBytes_clone(&*owner->contents.result);
4117 }
4118 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4119         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4120         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4121         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4122         return ret_arr;
4123 }
4124
4125 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4126 CHECK(!owner->result_ok);
4127         return APIError_clone(&*owner->contents.err);
4128 }
4129 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4130         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4131         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4132         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4133         uint32_t ret_ref = (uintptr_t)ret_copy;
4134         return ret_ref;
4135 }
4136
4137 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4138 CHECK(owner->result_ok);
4139         return ThirtyTwoBytes_clone(&*owner->contents.result);
4140 }
4141 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4142         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4143         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4144         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4145         return ret_arr;
4146 }
4147
4148 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4149 CHECK(!owner->result_ok);
4150         return APIError_clone(&*owner->contents.err);
4151 }
4152 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4153         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4154         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4155         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4156         uint32_t ret_ref = (uintptr_t)ret_copy;
4157         return ret_ref;
4158 }
4159
4160 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4161 CHECK(owner->result_ok);
4162         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4163 }
4164 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4165         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4166         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4167         uint32_t ret_ref = 0;
4168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4171         ret_ref = (uintptr_t)ret_var.inner;
4172         if (ret_var.is_owned) {
4173                 ret_ref |= 1;
4174         }
4175         return ret_ref;
4176 }
4177
4178 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4179 CHECK(!owner->result_ok);
4180         return DecodeError_clone(&*owner->contents.err);
4181 }
4182 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4183         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4184         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4185         uint32_t ret_ref = 0;
4186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4189         ret_ref = (uintptr_t)ret_var.inner;
4190         if (ret_var.is_owned) {
4191                 ret_ref |= 1;
4192         }
4193         return ret_ref;
4194 }
4195
4196 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4197 CHECK(owner->result_ok);
4198         return ChannelCounterparty_clone(&*owner->contents.result);
4199 }
4200 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4201         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4202         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4203         uint32_t ret_ref = 0;
4204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4207         ret_ref = (uintptr_t)ret_var.inner;
4208         if (ret_var.is_owned) {
4209                 ret_ref |= 1;
4210         }
4211         return ret_ref;
4212 }
4213
4214 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4215 CHECK(!owner->result_ok);
4216         return DecodeError_clone(&*owner->contents.err);
4217 }
4218 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4219         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4220         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4221         uint32_t ret_ref = 0;
4222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4225         ret_ref = (uintptr_t)ret_var.inner;
4226         if (ret_var.is_owned) {
4227                 ret_ref |= 1;
4228         }
4229         return ret_ref;
4230 }
4231
4232 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4233 CHECK(owner->result_ok);
4234         return ChannelDetails_clone(&*owner->contents.result);
4235 }
4236 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4237         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4238         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4239         uint32_t ret_ref = 0;
4240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4243         ret_ref = (uintptr_t)ret_var.inner;
4244         if (ret_var.is_owned) {
4245                 ret_ref |= 1;
4246         }
4247         return ret_ref;
4248 }
4249
4250 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4251 CHECK(!owner->result_ok);
4252         return DecodeError_clone(&*owner->contents.err);
4253 }
4254 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4255         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4256         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4257         uint32_t ret_ref = 0;
4258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4261         ret_ref = (uintptr_t)ret_var.inner;
4262         if (ret_var.is_owned) {
4263                 ret_ref |= 1;
4264         }
4265         return ret_ref;
4266 }
4267
4268 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4269 CHECK(owner->result_ok);
4270         return PhantomRouteHints_clone(&*owner->contents.result);
4271 }
4272 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4273         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4274         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4275         uint32_t ret_ref = 0;
4276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4279         ret_ref = (uintptr_t)ret_var.inner;
4280         if (ret_var.is_owned) {
4281                 ret_ref |= 1;
4282         }
4283         return ret_ref;
4284 }
4285
4286 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4287 CHECK(!owner->result_ok);
4288         return DecodeError_clone(&*owner->contents.err);
4289 }
4290 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4291         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4292         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4293         uint32_t ret_ref = 0;
4294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4297         ret_ref = (uintptr_t)ret_var.inner;
4298         if (ret_var.is_owned) {
4299                 ret_ref |= 1;
4300         }
4301         return ret_ref;
4302 }
4303
4304 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4305         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4306         for (size_t i = 0; i < ret.datalen; i++) {
4307                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4308         }
4309         return ret;
4310 }
4311 typedef struct LDKWatch_JCalls {
4312         atomic_size_t refcnt;
4313         uint32_t instance_ptr;
4314 } LDKWatch_JCalls;
4315 static void LDKWatch_JCalls_free(void* this_arg) {
4316         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4317         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4318                 FREE(j_calls);
4319         }
4320 }
4321 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4322         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4323         LDKOutPoint funding_txo_var = funding_txo;
4324         uint32_t funding_txo_ref = 0;
4325         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4326         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4327         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4328         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4329         if (funding_txo_var.is_owned) {
4330                 funding_txo_ref |= 1;
4331         }
4332         LDKChannelMonitor monitor_var = monitor;
4333         uint32_t monitor_ref = 0;
4334         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4335         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4336         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4337         monitor_ref = (uintptr_t)monitor_var.inner;
4338         if (monitor_var.is_owned) {
4339                 monitor_ref |= 1;
4340         }
4341         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4342         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4343         CHECK_ACCESS(ret_ptr);
4344         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4345         FREE((void*)ret);
4346         return ret_conv;
4347 }
4348 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4349         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4350         LDKOutPoint funding_txo_var = funding_txo;
4351         uint32_t funding_txo_ref = 0;
4352         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4353         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4354         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4355         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4356         if (funding_txo_var.is_owned) {
4357                 funding_txo_ref |= 1;
4358         }
4359         LDKChannelMonitorUpdate update_var = update;
4360         uint32_t update_ref = 0;
4361         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4362         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4363         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4364         update_ref = (uintptr_t)update_var.inner;
4365         if (update_var.is_owned) {
4366                 update_ref |= 1;
4367         }
4368         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4369         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4370         CHECK_ACCESS(ret_ptr);
4371         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4372         FREE((void*)ret);
4373         return ret_conv;
4374 }
4375 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4376         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4377         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4378         LDKCVec_MonitorEventZ ret_constr;
4379         ret_constr.datalen = ret->arr_len;
4380         if (ret_constr.datalen > 0)
4381                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4382         else
4383                 ret_constr.data = NULL;
4384         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4385         for (size_t o = 0; o < ret_constr.datalen; o++) {
4386                 uint32_t ret_conv_14 = ret_vals[o];
4387                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4388                 CHECK_ACCESS(ret_conv_14_ptr);
4389                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4390                 FREE((void*)ret_conv_14);
4391                 ret_constr.data[o] = ret_conv_14_conv;
4392         }
4393         return ret_constr;
4394 }
4395 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4396         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4397         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4398 }
4399 static inline LDKWatch LDKWatch_init (JSValue o) {
4400         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4401         atomic_init(&calls->refcnt, 1);
4402         calls->instance_ptr = o;
4403
4404         LDKWatch ret = {
4405                 .this_arg = (void*) calls,
4406                 .watch_channel = watch_channel_LDKWatch_jcall,
4407                 .update_channel = update_channel_LDKWatch_jcall,
4408                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4409                 .free = LDKWatch_JCalls_free,
4410         };
4411         return ret;
4412 }
4413 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4414         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4415         *res_ptr = LDKWatch_init(o);
4416         return (long)res_ptr;
4417 }
4418 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4419         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4420         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4421         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4422         LDKOutPoint funding_txo_conv;
4423         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4424         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4425         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4426         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4427         LDKChannelMonitor monitor_conv;
4428         monitor_conv.inner = (void*)(monitor & (~1));
4429         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4430         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4431         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4432         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4433         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4434         return (uint32_t)ret_conv;
4435 }
4436
4437 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4438         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4439         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4440         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4441         LDKOutPoint funding_txo_conv;
4442         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4443         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4444         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4445         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4446         LDKChannelMonitorUpdate update_conv;
4447         update_conv.inner = (void*)(update & (~1));
4448         update_conv.is_owned = (update & 1) || (update == 0);
4449         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4450         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4451         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4452         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4453         return (uint32_t)ret_conv;
4454 }
4455
4456 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4457         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4458         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4459         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4460         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4461         uint32_tArray ret_arr = NULL;
4462         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4463         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4464         for (size_t o = 0; o < ret_var.datalen; o++) {
4465                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4466                 *ret_conv_14_copy = ret_var.data[o];
4467                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4468                 ret_arr_ptr[o] = ret_conv_14_ref;
4469         }
4470         
4471         FREE(ret_var.data);
4472         return ret_arr;
4473 }
4474
4475 typedef struct LDKBroadcasterInterface_JCalls {
4476         atomic_size_t refcnt;
4477         uint32_t instance_ptr;
4478 } LDKBroadcasterInterface_JCalls;
4479 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4480         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4481         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4482                 FREE(j_calls);
4483         }
4484 }
4485 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4486         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4487         LDKTransaction tx_var = tx;
4488         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4489         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4490         Transaction_free(tx_var);
4491         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4492 }
4493 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4494         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4495         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4496 }
4497 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4498         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4499         atomic_init(&calls->refcnt, 1);
4500         calls->instance_ptr = o;
4501
4502         LDKBroadcasterInterface ret = {
4503                 .this_arg = (void*) calls,
4504                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4505                 .free = LDKBroadcasterInterface_JCalls_free,
4506         };
4507         return ret;
4508 }
4509 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4510         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4511         *res_ptr = LDKBroadcasterInterface_init(o);
4512         return (long)res_ptr;
4513 }
4514 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4515         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4516         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4517         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4518         LDKTransaction tx_ref;
4519         tx_ref.datalen = tx->arr_len;
4520         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4521         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4522         tx_ref.data_is_owned = true;
4523         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4524 }
4525
4526 typedef struct LDKKeysInterface_JCalls {
4527         atomic_size_t refcnt;
4528         uint32_t instance_ptr;
4529 } LDKKeysInterface_JCalls;
4530 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4531         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4532         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4533                 FREE(j_calls);
4534         }
4535 }
4536 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4537         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4538         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4539         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4540         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4541         CHECK_ACCESS(ret_ptr);
4542         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4543         FREE((void*)ret);
4544         return ret_conv;
4545 }
4546 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4547         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4548         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4549         LDKCVec_u8Z ret_ref;
4550         ret_ref.datalen = ret->arr_len;
4551         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4552         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4553         return ret_ref;
4554 }
4555 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4556         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4557         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4558         LDKShutdownScript ret_conv;
4559         ret_conv.inner = (void*)(ret & (~1));
4560         ret_conv.is_owned = (ret & 1) || (ret == 0);
4561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4562         return ret_conv;
4563 }
4564 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4565         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4566         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
4567         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4568         CHECK_ACCESS(ret_ptr);
4569         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4570         FREE((void*)ret);
4571         return ret_conv;
4572 }
4573 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4574         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4575         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4576         LDKThirtyTwoBytes ret_ref;
4577         CHECK(ret->arr_len == 32);
4578         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4579         return ret_ref;
4580 }
4581 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4582         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4583         LDKu8slice reader_var = reader;
4584         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4585         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4586         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4587         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4588         CHECK_ACCESS(ret_ptr);
4589         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4590         FREE((void*)ret);
4591         return ret_conv;
4592 }
4593 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4594         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4595         LDKu8slice hrp_bytes_var = hrp_bytes;
4596         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4597         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4598         LDKCVec_u5Z invoice_data_var = invoice_data;
4599         ptrArray invoice_data_arr = NULL;
4600         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4601         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4602         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4603                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4604                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4605         }
4606         
4607         FREE(invoice_data_var.data);
4608         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4609         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 24, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, (uint32_t)receipient_conv);
4610         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4611         CHECK_ACCESS(ret_ptr);
4612         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4613         FREE((void*)ret);
4614         return ret_conv;
4615 }
4616 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4617         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4618         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4619         LDKThirtyTwoBytes ret_ref;
4620         CHECK(ret->arr_len == 32);
4621         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4622         return ret_ref;
4623 }
4624 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4625         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4626         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4627 }
4628 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4629         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4630         atomic_init(&calls->refcnt, 1);
4631         calls->instance_ptr = o;
4632
4633         LDKKeysInterface ret = {
4634                 .this_arg = (void*) calls,
4635                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4636                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4637                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4638                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4639                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4640                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4641                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4642                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4643                 .free = LDKKeysInterface_JCalls_free,
4644         };
4645         return ret;
4646 }
4647 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4648         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4649         *res_ptr = LDKKeysInterface_init(o);
4650         return (long)res_ptr;
4651 }
4652 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4653         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4654         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4655         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4656         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4657         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4658         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4659         return (uint32_t)ret_conv;
4660 }
4661
4662 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4663         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4665         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4666         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4667         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4668         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4669         CVec_u8Z_free(ret_var);
4670         return ret_arr;
4671 }
4672
4673 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4676         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4677         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4678         uint32_t ret_ref = 0;
4679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4680         CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
4683         if (ret_var.is_owned) {
4684                 ret_ref |= 1;
4685         }
4686         return ret_ref;
4687 }
4688
4689 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) {
4690         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4692         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4693         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4694         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4695         return (uint32_t)ret_ret;
4696 }
4697
4698 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4699         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4701         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4702         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4703         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4704         return ret_arr;
4705 }
4706
4707 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4708         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4709         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4710         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4711         LDKu8slice reader_ref;
4712         reader_ref.datalen = reader->arr_len;
4713         reader_ref.data = reader->elems /* XXX reader leaks */;
4714         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4715         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4716         return (uint32_t)ret_conv;
4717 }
4718
4719 uint32_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray hrp_bytes, ptrArray invoice_data, uint32_t receipient) {
4720         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4721         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4722         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4723         LDKu8slice hrp_bytes_ref;
4724         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4725         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4726         LDKCVec_u5Z invoice_data_constr;
4727         invoice_data_constr.datalen = invoice_data->arr_len;
4728         if (invoice_data_constr.datalen > 0)
4729                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4730         else
4731                 invoice_data_constr.data = NULL;
4732         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4733         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4734                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4735                 
4736                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4737         }
4738         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4739         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4740         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4741         return (uint32_t)ret_conv;
4742 }
4743
4744 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4745         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4746         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4747         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4748         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4749         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4750         return ret_arr;
4751 }
4752
4753 typedef struct LDKFeeEstimator_JCalls {
4754         atomic_size_t refcnt;
4755         uint32_t instance_ptr;
4756 } LDKFeeEstimator_JCalls;
4757 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4758         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4759         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4760                 FREE(j_calls);
4761         }
4762 }
4763 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4764         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4765         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4766         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4767 }
4768 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4769         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4770         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4771 }
4772 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4773         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4774         atomic_init(&calls->refcnt, 1);
4775         calls->instance_ptr = o;
4776
4777         LDKFeeEstimator ret = {
4778                 .this_arg = (void*) calls,
4779                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4780                 .free = LDKFeeEstimator_JCalls_free,
4781         };
4782         return ret;
4783 }
4784 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4785         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4786         *res_ptr = LDKFeeEstimator_init(o);
4787         return (long)res_ptr;
4788 }
4789 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) {
4790         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4791         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4792         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4793         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4794         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4795         return ret_val;
4796 }
4797
4798 typedef struct LDKLogger_JCalls {
4799         atomic_size_t refcnt;
4800         uint32_t instance_ptr;
4801 } LDKLogger_JCalls;
4802 static void LDKLogger_JCalls_free(void* this_arg) {
4803         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4804         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4805                 FREE(j_calls);
4806         }
4807 }
4808 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4809         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4810         LDKRecord record_var = *record;
4811         uint32_t record_ref = 0;
4812         record_var = Record_clone(&record_var);
4813         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4814         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4815         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4816         record_ref = (uintptr_t)record_var.inner;
4817         if (record_var.is_owned) {
4818                 record_ref |= 1;
4819         }
4820         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4821 }
4822 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4823         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4824         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4825 }
4826 static inline LDKLogger LDKLogger_init (JSValue o) {
4827         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4828         atomic_init(&calls->refcnt, 1);
4829         calls->instance_ptr = o;
4830
4831         LDKLogger ret = {
4832                 .this_arg = (void*) calls,
4833                 .log = log_LDKLogger_jcall,
4834                 .free = LDKLogger_JCalls_free,
4835         };
4836         return ret;
4837 }
4838 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4839         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4840         *res_ptr = LDKLogger_init(o);
4841         return (long)res_ptr;
4842 }
4843 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4844         return ThirtyTwoBytes_clone(&owner->a);
4845 }
4846 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4847         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4848         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4849         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4850         return ret_arr;
4851 }
4852
4853 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4854         return &owner->b;
4855 }
4856 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4857         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4858         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4859         uint32_t ret_ref = 0;
4860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4863         ret_ref = (uintptr_t)ret_var.inner & ~1;
4864         return ret_ref;
4865 }
4866
4867 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4868 CHECK(owner->result_ok);
4869         return &*owner->contents.result;
4870 }
4871 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4872         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4873         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4874         return ret_ret;
4875 }
4876
4877 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4878 CHECK(!owner->result_ok);
4879         return DecodeError_clone(&*owner->contents.err);
4880 }
4881 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4882         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4883         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4884         uint32_t ret_ref = 0;
4885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4888         ret_ref = (uintptr_t)ret_var.inner;
4889         if (ret_var.is_owned) {
4890                 ret_ref |= 1;
4891         }
4892         return ret_ref;
4893 }
4894
4895 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4896 CHECK(owner->result_ok);
4897         return ChannelConfig_clone(&*owner->contents.result);
4898 }
4899 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4900         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4901         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4902         uint32_t ret_ref = 0;
4903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4906         ret_ref = (uintptr_t)ret_var.inner;
4907         if (ret_var.is_owned) {
4908                 ret_ref |= 1;
4909         }
4910         return ret_ref;
4911 }
4912
4913 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4914 CHECK(!owner->result_ok);
4915         return DecodeError_clone(&*owner->contents.err);
4916 }
4917 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4918         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4919         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4920         uint32_t ret_ref = 0;
4921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4924         ret_ref = (uintptr_t)ret_var.inner;
4925         if (ret_var.is_owned) {
4926                 ret_ref |= 1;
4927         }
4928         return ret_ref;
4929 }
4930
4931 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4932 CHECK(owner->result_ok);
4933         return OutPoint_clone(&*owner->contents.result);
4934 }
4935 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4936         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4937         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4938         uint32_t ret_ref = 0;
4939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4942         ret_ref = (uintptr_t)ret_var.inner;
4943         if (ret_var.is_owned) {
4944                 ret_ref |= 1;
4945         }
4946         return ret_ref;
4947 }
4948
4949 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4950 CHECK(!owner->result_ok);
4951         return DecodeError_clone(&*owner->contents.err);
4952 }
4953 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4954         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4955         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4956         uint32_t ret_ref = 0;
4957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4960         ret_ref = (uintptr_t)ret_var.inner;
4961         if (ret_var.is_owned) {
4962                 ret_ref |= 1;
4963         }
4964         return ret_ref;
4965 }
4966
4967 typedef struct LDKType_JCalls {
4968         atomic_size_t refcnt;
4969         uint32_t instance_ptr;
4970 } LDKType_JCalls;
4971 static void LDKType_JCalls_free(void* this_arg) {
4972         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4973         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4974                 FREE(j_calls);
4975         }
4976 }
4977 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4978         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4979         return js_invoke_function_0(j_calls->instance_ptr, 28);
4980 }
4981 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4982         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4983         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
4984         LDKStr ret_conv = str_ref_to_owned_c(ret);
4985         return ret_conv;
4986 }
4987 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4988         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4989         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
4990         LDKCVec_u8Z ret_ref;
4991         ret_ref.datalen = ret->arr_len;
4992         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4993         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4994         return ret_ref;
4995 }
4996 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4997         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4998         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4999 }
5000 static inline LDKType LDKType_init (JSValue o) {
5001         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5002         atomic_init(&calls->refcnt, 1);
5003         calls->instance_ptr = o;
5004
5005         LDKType ret = {
5006                 .this_arg = (void*) calls,
5007                 .type_id = type_id_LDKType_jcall,
5008                 .debug_str = debug_str_LDKType_jcall,
5009                 .write = write_LDKType_jcall,
5010                 .cloned = LDKType_JCalls_cloned,
5011                 .free = LDKType_JCalls_free,
5012         };
5013         return ret;
5014 }
5015 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5016         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5017         *res_ptr = LDKType_init(o);
5018         return (long)res_ptr;
5019 }
5020 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5021         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5022         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5023         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5024         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5025         return ret_val;
5026 }
5027
5028 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5029         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5030         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5031         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5032         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5033         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5034         Str_free(ret_str);
5035         return ret_conv;
5036 }
5037
5038 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5039         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5040         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5041         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5042         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5043         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5044         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5045         CVec_u8Z_free(ret_var);
5046         return ret_arr;
5047 }
5048
5049 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5050         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5051         switch(obj->tag) {
5052                 case LDKCOption_TypeZ_Some: return 0;
5053                 case LDKCOption_TypeZ_None: return 1;
5054                 default: abort();
5055         }
5056 }
5057 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5058         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5059         assert(obj->tag == LDKCOption_TypeZ_Some);
5060                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5061                         *some_ret = Type_clone(&obj->some);
5062         return (uint32_t)some_ret;
5063 }
5064 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5065 CHECK(owner->result_ok);
5066         return COption_TypeZ_clone(&*owner->contents.result);
5067 }
5068 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5069         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5070         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5071         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5072         uint32_t ret_ref = (uintptr_t)ret_copy;
5073         return ret_ref;
5074 }
5075
5076 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5077 CHECK(!owner->result_ok);
5078         return DecodeError_clone(&*owner->contents.err);
5079 }
5080 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5081         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5082         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5083         uint32_t ret_ref = 0;
5084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5087         ret_ref = (uintptr_t)ret_var.inner;
5088         if (ret_var.is_owned) {
5089                 ret_ref |= 1;
5090         }
5091         return ret_ref;
5092 }
5093
5094 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5095         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5096         switch(obj->tag) {
5097                 case LDKPaymentError_Invoice: return 0;
5098                 case LDKPaymentError_Routing: return 1;
5099                 case LDKPaymentError_Sending: return 2;
5100                 default: abort();
5101         }
5102 }
5103 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5104         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5105         assert(obj->tag == LDKPaymentError_Invoice);
5106                         LDKStr invoice_str = obj->invoice;
5107                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5108         return invoice_conv;
5109 }
5110 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5111         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5112         assert(obj->tag == LDKPaymentError_Routing);
5113                         LDKLightningError routing_var = obj->routing;
5114                         uint32_t routing_ref = 0;
5115                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5116                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5117                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5118                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5119         return routing_ref;
5120 }
5121 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5122         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5123         assert(obj->tag == LDKPaymentError_Sending);
5124                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5125         return sending_ref;
5126 }
5127 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5128 CHECK(owner->result_ok);
5129         return ThirtyTwoBytes_clone(&*owner->contents.result);
5130 }
5131 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5132         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5133         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5134         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5135         return ret_arr;
5136 }
5137
5138 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5139 CHECK(!owner->result_ok);
5140         return PaymentError_clone(&*owner->contents.err);
5141 }
5142 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5143         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5144         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5145         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5146         uint32_t ret_ref = (uintptr_t)ret_copy;
5147         return ret_ref;
5148 }
5149
5150 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5151         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5152         switch(obj->tag) {
5153                 case LDKParseError_Bech32Error: return 0;
5154                 case LDKParseError_ParseAmountError: return 1;
5155                 case LDKParseError_MalformedSignature: return 2;
5156                 case LDKParseError_BadPrefix: return 3;
5157                 case LDKParseError_UnknownCurrency: return 4;
5158                 case LDKParseError_UnknownSiPrefix: return 5;
5159                 case LDKParseError_MalformedHRP: return 6;
5160                 case LDKParseError_TooShortDataPart: return 7;
5161                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5162                 case LDKParseError_DescriptionDecodeError: return 9;
5163                 case LDKParseError_PaddingError: return 10;
5164                 case LDKParseError_IntegerOverflowError: return 11;
5165                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5166                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5167                 case LDKParseError_InvalidScriptHashLength: return 14;
5168                 case LDKParseError_InvalidRecoveryId: return 15;
5169                 case LDKParseError_InvalidSliceLength: return 16;
5170                 case LDKParseError_Skip: return 17;
5171                 default: abort();
5172         }
5173 }
5174 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5175         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5176         assert(obj->tag == LDKParseError_Bech32Error);
5177                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5178         return bech32_error_ref;
5179 }
5180 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5181         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5182         assert(obj->tag == LDKParseError_ParseAmountError);
5183                         /*obj->parse_amount_error*/
5184         return 0;
5185 }
5186 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5187         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5188         assert(obj->tag == LDKParseError_MalformedSignature);
5189                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5190         return malformed_signature_conv;
5191 }
5192 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5193         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5194         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5195                         /*obj->description_decode_error*/
5196         return 0;
5197 }
5198 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5199         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5200         assert(obj->tag == LDKParseError_InvalidSliceLength);
5201                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5202                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5203         return invalid_slice_length_conv;
5204 }
5205 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5206 CHECK(owner->result_ok);
5207         return SiPrefix_clone(&*owner->contents.result);
5208 }
5209 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5210         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5211         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5212         return ret_conv;
5213 }
5214
5215 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5216 CHECK(!owner->result_ok);
5217         return ParseError_clone(&*owner->contents.err);
5218 }
5219 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5220         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5221         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5222         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5223         uint32_t ret_ref = (uintptr_t)ret_copy;
5224         return ret_ref;
5225 }
5226
5227 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5228         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5229         switch(obj->tag) {
5230                 case LDKParseOrSemanticError_ParseError: return 0;
5231                 case LDKParseOrSemanticError_SemanticError: return 1;
5232                 default: abort();
5233         }
5234 }
5235 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5236         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5237         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5238                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5239         return parse_error_ref;
5240 }
5241 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5242         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5243         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5244                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5245         return semantic_error_conv;
5246 }
5247 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5248 CHECK(owner->result_ok);
5249         return Invoice_clone(&*owner->contents.result);
5250 }
5251 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5252         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5253         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5254         uint32_t ret_ref = 0;
5255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5256         CHECK((((uintptr_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 = (uintptr_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 LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5266 CHECK(!owner->result_ok);
5267         return ParseOrSemanticError_clone(&*owner->contents.err);
5268 }
5269 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5270         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5271         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5272         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5273         uint32_t ret_ref = (uintptr_t)ret_copy;
5274         return ret_ref;
5275 }
5276
5277 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5278 CHECK(owner->result_ok);
5279         return SignedRawInvoice_clone(&*owner->contents.result);
5280 }
5281 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
5282         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5283         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5284         uint32_t ret_ref = 0;
5285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5288         ret_ref = (uintptr_t)ret_var.inner;
5289         if (ret_var.is_owned) {
5290                 ret_ref |= 1;
5291         }
5292         return ret_ref;
5293 }
5294
5295 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5296 CHECK(!owner->result_ok);
5297         return ParseError_clone(&*owner->contents.err);
5298 }
5299 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
5300         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5301         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5302         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5303         uint32_t ret_ref = (uintptr_t)ret_copy;
5304         return ret_ref;
5305 }
5306
5307 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5308         return RawInvoice_clone(&owner->a);
5309 }
5310 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5311         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5312         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5313         uint32_t ret_ref = 0;
5314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5317         ret_ref = (uintptr_t)ret_var.inner;
5318         if (ret_var.is_owned) {
5319                 ret_ref |= 1;
5320         }
5321         return ret_ref;
5322 }
5323
5324 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5325         return ThirtyTwoBytes_clone(&owner->b);
5326 }
5327 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5328         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5329         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5330         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5331         return ret_arr;
5332 }
5333
5334 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5335         return InvoiceSignature_clone(&owner->c);
5336 }
5337 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5338         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5339         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5340         uint32_t ret_ref = 0;
5341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5344         ret_ref = (uintptr_t)ret_var.inner;
5345         if (ret_var.is_owned) {
5346                 ret_ref |= 1;
5347         }
5348         return ret_ref;
5349 }
5350
5351 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5352 CHECK(owner->result_ok);
5353         return PayeePubKey_clone(&*owner->contents.result);
5354 }
5355 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5356         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5357         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5358         uint32_t ret_ref = 0;
5359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5362         ret_ref = (uintptr_t)ret_var.inner;
5363         if (ret_var.is_owned) {
5364                 ret_ref |= 1;
5365         }
5366         return ret_ref;
5367 }
5368
5369 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5370 CHECK(!owner->result_ok);
5371         return *owner->contents.err;
5372 }
5373 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5374         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5375         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5376         return ret_conv;
5377 }
5378
5379 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5380         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5381         for (size_t i = 0; i < ret.datalen; i++) {
5382                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5383         }
5384         return ret;
5385 }
5386 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5387 CHECK(owner->result_ok);
5388         return PositiveTimestamp_clone(&*owner->contents.result);
5389 }
5390 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5391         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5392         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5393         uint32_t ret_ref = 0;
5394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5397         ret_ref = (uintptr_t)ret_var.inner;
5398         if (ret_var.is_owned) {
5399                 ret_ref |= 1;
5400         }
5401         return ret_ref;
5402 }
5403
5404 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5405 CHECK(!owner->result_ok);
5406         return CreationError_clone(&*owner->contents.err);
5407 }
5408 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5409         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5410         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5411         return ret_conv;
5412 }
5413
5414 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5415 CHECK(owner->result_ok);
5416         return *owner->contents.result;
5417 }
5418 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5419         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5420         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5421 }
5422
5423 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5424 CHECK(!owner->result_ok);
5425         return SemanticError_clone(&*owner->contents.err);
5426 }
5427 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5428         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5429         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5430         return ret_conv;
5431 }
5432
5433 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5434 CHECK(owner->result_ok);
5435         return Invoice_clone(&*owner->contents.result);
5436 }
5437 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5438         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5439         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5440         uint32_t ret_ref = 0;
5441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5444         ret_ref = (uintptr_t)ret_var.inner;
5445         if (ret_var.is_owned) {
5446                 ret_ref |= 1;
5447         }
5448         return ret_ref;
5449 }
5450
5451 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5452 CHECK(!owner->result_ok);
5453         return SemanticError_clone(&*owner->contents.err);
5454 }
5455 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5456         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5457         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5458         return ret_conv;
5459 }
5460
5461 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5462 CHECK(owner->result_ok);
5463         return Description_clone(&*owner->contents.result);
5464 }
5465 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5466         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5467         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5468         uint32_t ret_ref = 0;
5469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5472         ret_ref = (uintptr_t)ret_var.inner;
5473         if (ret_var.is_owned) {
5474                 ret_ref |= 1;
5475         }
5476         return ret_ref;
5477 }
5478
5479 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5480 CHECK(!owner->result_ok);
5481         return CreationError_clone(&*owner->contents.err);
5482 }
5483 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5484         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5485         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5486         return ret_conv;
5487 }
5488
5489 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5490 CHECK(owner->result_ok);
5491         return PrivateRoute_clone(&*owner->contents.result);
5492 }
5493 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5494         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5495         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5496         uint32_t ret_ref = 0;
5497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5500         ret_ref = (uintptr_t)ret_var.inner;
5501         if (ret_var.is_owned) {
5502                 ret_ref |= 1;
5503         }
5504         return ret_ref;
5505 }
5506
5507 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5508 CHECK(!owner->result_ok);
5509         return CreationError_clone(&*owner->contents.err);
5510 }
5511 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5512         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5513         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5514         return ret_conv;
5515 }
5516
5517 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5518 CHECK(owner->result_ok);
5519         return *owner->contents.result;
5520 }
5521 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5522         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5523         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5524         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5525         return ret_conv;
5526 }
5527
5528 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5529 CHECK(!owner->result_ok);
5530         return *owner->contents.err;
5531 }
5532 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5533         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5534         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5535         return ret_conv;
5536 }
5537
5538 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5539 CHECK(owner->result_ok);
5540         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5541 }
5542 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5543         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5544         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5545         uint32_t ret_ref = 0;
5546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5549         ret_ref = (uintptr_t)ret_var.inner;
5550         if (ret_var.is_owned) {
5551                 ret_ref |= 1;
5552         }
5553         return ret_ref;
5554 }
5555
5556 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5557 CHECK(!owner->result_ok);
5558         return DecodeError_clone(&*owner->contents.err);
5559 }
5560 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5561         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5562         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5563         uint32_t ret_ref = 0;
5564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5567         ret_ref = (uintptr_t)ret_var.inner;
5568         if (ret_var.is_owned) {
5569                 ret_ref |= 1;
5570         }
5571         return ret_ref;
5572 }
5573
5574 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5575         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5576         switch(obj->tag) {
5577                 case LDKCOption_MonitorEventZ_Some: return 0;
5578                 case LDKCOption_MonitorEventZ_None: return 1;
5579                 default: abort();
5580         }
5581 }
5582 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5583         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5584         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5585                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5586         return some_ref;
5587 }
5588 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5589 CHECK(owner->result_ok);
5590         return COption_MonitorEventZ_clone(&*owner->contents.result);
5591 }
5592 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5593         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5594         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5595         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5596         uint32_t ret_ref = (uintptr_t)ret_copy;
5597         return ret_ref;
5598 }
5599
5600 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5601 CHECK(!owner->result_ok);
5602         return DecodeError_clone(&*owner->contents.err);
5603 }
5604 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5605         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5606         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5607         uint32_t ret_ref = 0;
5608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5611         ret_ref = (uintptr_t)ret_var.inner;
5612         if (ret_var.is_owned) {
5613                 ret_ref |= 1;
5614         }
5615         return ret_ref;
5616 }
5617
5618 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5619 CHECK(owner->result_ok);
5620         return HTLCUpdate_clone(&*owner->contents.result);
5621 }
5622 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5623         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5624         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5625         uint32_t ret_ref = 0;
5626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5629         ret_ref = (uintptr_t)ret_var.inner;
5630         if (ret_var.is_owned) {
5631                 ret_ref |= 1;
5632         }
5633         return ret_ref;
5634 }
5635
5636 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5637 CHECK(!owner->result_ok);
5638         return DecodeError_clone(&*owner->contents.err);
5639 }
5640 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5641         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5642         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5643         uint32_t ret_ref = 0;
5644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5647         ret_ref = (uintptr_t)ret_var.inner;
5648         if (ret_var.is_owned) {
5649                 ret_ref |= 1;
5650         }
5651         return ret_ref;
5652 }
5653
5654 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5655         return OutPoint_clone(&owner->a);
5656 }
5657 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5658         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5659         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5660         uint32_t ret_ref = 0;
5661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5664         ret_ref = (uintptr_t)ret_var.inner;
5665         if (ret_var.is_owned) {
5666                 ret_ref |= 1;
5667         }
5668         return ret_ref;
5669 }
5670
5671 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5672         return CVec_u8Z_clone(&owner->b);
5673 }
5674 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5675         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5676         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5677         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5678         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5679         CVec_u8Z_free(ret_var);
5680         return ret_arr;
5681 }
5682
5683 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5684         return owner->a;
5685 }
5686 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5687         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5688         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
5689         return ret_val;
5690 }
5691
5692 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5693         return CVec_u8Z_clone(&owner->b);
5694 }
5695 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5696         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5697         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5698         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5699         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5700         CVec_u8Z_free(ret_var);
5701         return ret_arr;
5702 }
5703
5704 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5705         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5706         for (size_t i = 0; i < ret.datalen; i++) {
5707                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5708         }
5709         return ret;
5710 }
5711 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5712         return ThirtyTwoBytes_clone(&owner->a);
5713 }
5714 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5715         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5716         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5717         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5718         return ret_arr;
5719 }
5720
5721 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5722         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5723 }
5724 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5725         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5726         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5727         uint32_tArray ret_arr = NULL;
5728         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5729         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5730         for (size_t v = 0; v < ret_var.datalen; v++) {
5731                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5732                 *ret_conv_21_conv = ret_var.data[v];
5733                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5734         }
5735         
5736         FREE(ret_var.data);
5737         return ret_arr;
5738 }
5739
5740 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5741         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
5742         for (size_t i = 0; i < ret.datalen; i++) {
5743                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5744         }
5745         return ret;
5746 }
5747 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5748         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5749         for (size_t i = 0; i < ret.datalen; i++) {
5750                 ret.data[i] = Event_clone(&orig->data[i]);
5751         }
5752         return ret;
5753 }
5754 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5755         return owner->a;
5756 }
5757 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5758         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5759         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
5760         return ret_val;
5761 }
5762
5763 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5764         return TxOut_clone(&owner->b);
5765 }
5766 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5767         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5768         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5769         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5770         return (uint32_t)ret_ref;
5771 }
5772
5773 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5774         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5775         for (size_t i = 0; i < ret.datalen; i++) {
5776                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5777         }
5778         return ret;
5779 }
5780 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5781         return ThirtyTwoBytes_clone(&owner->a);
5782 }
5783 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5784         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5785         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5786         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5787         return ret_arr;
5788 }
5789
5790 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5791         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5792 }
5793 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5794         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5795         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5796         uint32_tArray ret_arr = NULL;
5797         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5798         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5799         for (size_t u = 0; u < ret_var.datalen; u++) {
5800                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5801                 *ret_conv_20_conv = ret_var.data[u];
5802                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5803         }
5804         
5805         FREE(ret_var.data);
5806         return ret_arr;
5807 }
5808
5809 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5810         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 };
5811         for (size_t i = 0; i < ret.datalen; i++) {
5812                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5813         }
5814         return ret;
5815 }
5816 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5817         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5818         switch(obj->tag) {
5819                 case LDKBalance_ClaimableOnChannelClose: return 0;
5820                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5821                 case LDKBalance_ContentiousClaimable: return 2;
5822                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5823                 default: abort();
5824         }
5825 }
5826 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5827         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5828         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5829         return obj->claimable_on_channel_close.claimable_amount_satoshis;
5830 }
5831 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5832         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5833         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5834         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5835 }
5836 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5837         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5838         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5839         return obj->claimable_awaiting_confirmations.confirmation_height;
5840 }
5841 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5842         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5843         assert(obj->tag == LDKBalance_ContentiousClaimable);
5844         return obj->contentious_claimable.claimable_amount_satoshis;
5845 }
5846 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5847         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5848         assert(obj->tag == LDKBalance_ContentiousClaimable);
5849         return obj->contentious_claimable.timeout_height;
5850 }
5851 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5852         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5853         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5854         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5855 }
5856 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5857         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5858         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5859         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5860 }
5861 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5862         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5863         for (size_t i = 0; i < ret.datalen; i++) {
5864                 ret.data[i] = Balance_clone(&orig->data[i]);
5865         }
5866         return ret;
5867 }
5868 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5869         return ThirtyTwoBytes_clone(&owner->a);
5870 }
5871 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5872         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5873         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5874         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5875         return ret_arr;
5876 }
5877
5878 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5879         return ChannelMonitor_clone(&owner->b);
5880 }
5881 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5882         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5883         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5884         uint32_t ret_ref = 0;
5885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5888         ret_ref = (uintptr_t)ret_var.inner;
5889         if (ret_var.is_owned) {
5890                 ret_ref |= 1;
5891         }
5892         return ret_ref;
5893 }
5894
5895 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5896 CHECK(owner->result_ok);
5897         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5898 }
5899 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5900         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5901         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5902         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5903         return ((uint32_t)ret_conv);
5904 }
5905
5906 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5907 CHECK(!owner->result_ok);
5908         return DecodeError_clone(&*owner->contents.err);
5909 }
5910 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5911         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5912         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5913         uint32_t ret_ref = 0;
5914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5917         ret_ref = (uintptr_t)ret_var.inner;
5918         if (ret_var.is_owned) {
5919                 ret_ref |= 1;
5920         }
5921         return ret_ref;
5922 }
5923
5924 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5925 CHECK(owner->result_ok);
5926         return *owner->contents.result;
5927 }
5928 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5929         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5930         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5931 }
5932
5933 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5934 CHECK(!owner->result_ok);
5935         return LightningError_clone(&*owner->contents.err);
5936 }
5937 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5938         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5939         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5940         uint32_t ret_ref = 0;
5941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5944         ret_ref = (uintptr_t)ret_var.inner;
5945         if (ret_var.is_owned) {
5946                 ret_ref |= 1;
5947         }
5948         return ret_ref;
5949 }
5950
5951 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5952         return owner->a;
5953 }
5954 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5955         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5956         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5957         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5958         return ret_arr;
5959 }
5960
5961 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5962         return Type_clone(&owner->b);
5963 }
5964 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
5965         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5966         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5967         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
5968         return (uint32_t)ret_ret;
5969 }
5970
5971 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5972         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5973         for (size_t i = 0; i < ret.datalen; i++) {
5974                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5975         }
5976         return ret;
5977 }
5978 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5979 CHECK(owner->result_ok);
5980         return *owner->contents.result;
5981 }
5982 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
5983         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5984         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
5985         return ret_val;
5986 }
5987
5988 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5989 CHECK(!owner->result_ok);
5990         return LightningError_clone(&*owner->contents.err);
5991 }
5992 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
5993         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5994         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5995         uint32_t ret_ref = 0;
5996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5999         ret_ref = (uintptr_t)ret_var.inner;
6000         if (ret_var.is_owned) {
6001                 ret_ref |= 1;
6002         }
6003         return ret_ref;
6004 }
6005
6006 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6007         return ChannelAnnouncement_clone(&owner->a);
6008 }
6009 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
6010         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6011         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
6012         uint32_t ret_ref = 0;
6013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6016         ret_ref = (uintptr_t)ret_var.inner;
6017         if (ret_var.is_owned) {
6018                 ret_ref |= 1;
6019         }
6020         return ret_ref;
6021 }
6022
6023 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6024         return ChannelUpdate_clone(&owner->b);
6025 }
6026 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
6027         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6028         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
6029         uint32_t ret_ref = 0;
6030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6033         ret_ref = (uintptr_t)ret_var.inner;
6034         if (ret_var.is_owned) {
6035                 ret_ref |= 1;
6036         }
6037         return ret_ref;
6038 }
6039
6040 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6041         return ChannelUpdate_clone(&owner->c);
6042 }
6043 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
6044         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6045         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
6046         uint32_t ret_ref = 0;
6047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6050         ret_ref = (uintptr_t)ret_var.inner;
6051         if (ret_var.is_owned) {
6052                 ret_ref |= 1;
6053         }
6054         return ret_ref;
6055 }
6056
6057 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6058         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6059         for (size_t i = 0; i < ret.datalen; i++) {
6060                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6061         }
6062         return ret;
6063 }
6064 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6065         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6066         for (size_t i = 0; i < ret.datalen; i++) {
6067                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6068         }
6069         return ret;
6070 }
6071 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6072         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6073         switch(obj->tag) {
6074                 case LDKCOption_NetAddressZ_Some: return 0;
6075                 case LDKCOption_NetAddressZ_None: return 1;
6076                 default: abort();
6077         }
6078 }
6079 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6080         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6081         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6082                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6083         return some_ref;
6084 }
6085 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6086 CHECK(owner->result_ok);
6087         return CVec_u8Z_clone(&*owner->contents.result);
6088 }
6089 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6090         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6091         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6092         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6093         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6094         CVec_u8Z_free(ret_var);
6095         return ret_arr;
6096 }
6097
6098 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6099 CHECK(!owner->result_ok);
6100         return PeerHandleError_clone(&*owner->contents.err);
6101 }
6102 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6103         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6104         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6105         uint32_t ret_ref = 0;
6106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6109         ret_ref = (uintptr_t)ret_var.inner;
6110         if (ret_var.is_owned) {
6111                 ret_ref |= 1;
6112         }
6113         return ret_ref;
6114 }
6115
6116 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6117 CHECK(owner->result_ok);
6118         return *owner->contents.result;
6119 }
6120 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6121         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6122         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6123 }
6124
6125 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6126 CHECK(!owner->result_ok);
6127         return PeerHandleError_clone(&*owner->contents.err);
6128 }
6129 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6130         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6131         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6132         uint32_t ret_ref = 0;
6133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6136         ret_ref = (uintptr_t)ret_var.inner;
6137         if (ret_var.is_owned) {
6138                 ret_ref |= 1;
6139         }
6140         return ret_ref;
6141 }
6142
6143 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6144 CHECK(owner->result_ok);
6145         return *owner->contents.result;
6146 }
6147 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6148         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6149         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6150         return ret_val;
6151 }
6152
6153 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6154 CHECK(!owner->result_ok);
6155         return PeerHandleError_clone(&*owner->contents.err);
6156 }
6157 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6158         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6159         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6160         uint32_t ret_ref = 0;
6161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6164         ret_ref = (uintptr_t)ret_var.inner;
6165         if (ret_var.is_owned) {
6166                 ret_ref |= 1;
6167         }
6168         return ret_ref;
6169 }
6170
6171 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6172 CHECK(owner->result_ok);
6173         return NodeId_clone(&*owner->contents.result);
6174 }
6175 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6176         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6177         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6178         uint32_t ret_ref = 0;
6179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6182         ret_ref = (uintptr_t)ret_var.inner;
6183         if (ret_var.is_owned) {
6184                 ret_ref |= 1;
6185         }
6186         return ret_ref;
6187 }
6188
6189 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6190 CHECK(!owner->result_ok);
6191         return DecodeError_clone(&*owner->contents.err);
6192 }
6193 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6194         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6195         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6196         uint32_t ret_ref = 0;
6197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6200         ret_ref = (uintptr_t)ret_var.inner;
6201         if (ret_var.is_owned) {
6202                 ret_ref |= 1;
6203         }
6204         return ret_ref;
6205 }
6206
6207 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6208 CHECK(owner->result_ok);
6209         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6210 }
6211 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6212         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6213         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6214         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6215         uint32_t ret_ref = (uintptr_t)ret_copy;
6216         return ret_ref;
6217 }
6218
6219 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6220 CHECK(!owner->result_ok);
6221         return DecodeError_clone(&*owner->contents.err);
6222 }
6223 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6224         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6225         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6226         uint32_t ret_ref = 0;
6227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6230         ret_ref = (uintptr_t)ret_var.inner;
6231         if (ret_var.is_owned) {
6232                 ret_ref |= 1;
6233         }
6234         return ret_ref;
6235 }
6236
6237 typedef struct LDKAccess_JCalls {
6238         atomic_size_t refcnt;
6239         uint32_t instance_ptr;
6240 } LDKAccess_JCalls;
6241 static void LDKAccess_JCalls_free(void* this_arg) {
6242         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6243         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6244                 FREE(j_calls);
6245         }
6246 }
6247 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6248         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6249         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6250         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6251         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
6252         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6253         CHECK_ACCESS(ret_ptr);
6254         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6255         FREE((void*)ret);
6256         return ret_conv;
6257 }
6258 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6259         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6260         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6261 }
6262 static inline LDKAccess LDKAccess_init (JSValue o) {
6263         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6264         atomic_init(&calls->refcnt, 1);
6265         calls->instance_ptr = o;
6266
6267         LDKAccess ret = {
6268                 .this_arg = (void*) calls,
6269                 .get_utxo = get_utxo_LDKAccess_jcall,
6270                 .free = LDKAccess_JCalls_free,
6271         };
6272         return ret;
6273 }
6274 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6275         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6276         *res_ptr = LDKAccess_init(o);
6277         return (long)res_ptr;
6278 }
6279 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) {
6280         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6281         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6282         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6283         unsigned char genesis_hash_arr[32];
6284         CHECK(genesis_hash->arr_len == 32);
6285         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6286         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6287         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6288         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6289         return (uint32_t)ret_conv;
6290 }
6291
6292 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6293         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6294         switch(obj->tag) {
6295                 case LDKCOption_AccessZ_Some: return 0;
6296                 case LDKCOption_AccessZ_None: return 1;
6297                 default: abort();
6298         }
6299 }
6300 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6301         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6302         assert(obj->tag == LDKCOption_AccessZ_Some);
6303                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6304                         *some_ret = obj->some;
6305                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6306                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6307                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6308                                 LDKAccess_JCalls_cloned(&(*some_ret));
6309                         }
6310         return (uint32_t)some_ret;
6311 }
6312 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6313 CHECK(owner->result_ok);
6314         return ChannelUpdateInfo_clone(&*owner->contents.result);
6315 }
6316 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6317         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6318         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6319         uint32_t ret_ref = 0;
6320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6323         ret_ref = (uintptr_t)ret_var.inner;
6324         if (ret_var.is_owned) {
6325                 ret_ref |= 1;
6326         }
6327         return ret_ref;
6328 }
6329
6330 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6331 CHECK(!owner->result_ok);
6332         return DecodeError_clone(&*owner->contents.err);
6333 }
6334 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6335         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6336         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6337         uint32_t ret_ref = 0;
6338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6341         ret_ref = (uintptr_t)ret_var.inner;
6342         if (ret_var.is_owned) {
6343                 ret_ref |= 1;
6344         }
6345         return ret_ref;
6346 }
6347
6348 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6349 CHECK(owner->result_ok);
6350         return ChannelInfo_clone(&*owner->contents.result);
6351 }
6352 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6353         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6354         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6355         uint32_t ret_ref = 0;
6356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6359         ret_ref = (uintptr_t)ret_var.inner;
6360         if (ret_var.is_owned) {
6361                 ret_ref |= 1;
6362         }
6363         return ret_ref;
6364 }
6365
6366 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6367 CHECK(!owner->result_ok);
6368         return DecodeError_clone(&*owner->contents.err);
6369 }
6370 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6371         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6372         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6373         uint32_t ret_ref = 0;
6374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6377         ret_ref = (uintptr_t)ret_var.inner;
6378         if (ret_var.is_owned) {
6379                 ret_ref |= 1;
6380         }
6381         return ret_ref;
6382 }
6383
6384 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6385 CHECK(owner->result_ok);
6386         return RoutingFees_clone(&*owner->contents.result);
6387 }
6388 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6389         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6390         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6391         uint32_t ret_ref = 0;
6392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6395         ret_ref = (uintptr_t)ret_var.inner;
6396         if (ret_var.is_owned) {
6397                 ret_ref |= 1;
6398         }
6399         return ret_ref;
6400 }
6401
6402 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6403 CHECK(!owner->result_ok);
6404         return DecodeError_clone(&*owner->contents.err);
6405 }
6406 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6407         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6408         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6409         uint32_t ret_ref = 0;
6410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6413         ret_ref = (uintptr_t)ret_var.inner;
6414         if (ret_var.is_owned) {
6415                 ret_ref |= 1;
6416         }
6417         return ret_ref;
6418 }
6419
6420 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6421 CHECK(owner->result_ok);
6422         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6423 }
6424 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6425         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6426         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6427         uint32_t ret_ref = 0;
6428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6431         ret_ref = (uintptr_t)ret_var.inner;
6432         if (ret_var.is_owned) {
6433                 ret_ref |= 1;
6434         }
6435         return ret_ref;
6436 }
6437
6438 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6439 CHECK(!owner->result_ok);
6440         return DecodeError_clone(&*owner->contents.err);
6441 }
6442 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6443         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6444         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6445         uint32_t ret_ref = 0;
6446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6449         ret_ref = (uintptr_t)ret_var.inner;
6450         if (ret_var.is_owned) {
6451                 ret_ref |= 1;
6452         }
6453         return ret_ref;
6454 }
6455
6456 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6457         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6458         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6459         return ret;
6460 }
6461 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6462 CHECK(owner->result_ok);
6463         return NodeInfo_clone(&*owner->contents.result);
6464 }
6465 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6466         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6467         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6468         uint32_t ret_ref = 0;
6469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6472         ret_ref = (uintptr_t)ret_var.inner;
6473         if (ret_var.is_owned) {
6474                 ret_ref |= 1;
6475         }
6476         return ret_ref;
6477 }
6478
6479 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6480 CHECK(!owner->result_ok);
6481         return DecodeError_clone(&*owner->contents.err);
6482 }
6483 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6484         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6485         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6486         uint32_t ret_ref = 0;
6487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6490         ret_ref = (uintptr_t)ret_var.inner;
6491         if (ret_var.is_owned) {
6492                 ret_ref |= 1;
6493         }
6494         return ret_ref;
6495 }
6496
6497 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6498 CHECK(owner->result_ok);
6499         return NetworkGraph_clone(&*owner->contents.result);
6500 }
6501 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6502         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6503         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6504         uint32_t ret_ref = 0;
6505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6508         ret_ref = (uintptr_t)ret_var.inner;
6509         if (ret_var.is_owned) {
6510                 ret_ref |= 1;
6511         }
6512         return ret_ref;
6513 }
6514
6515 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6516 CHECK(!owner->result_ok);
6517         return DecodeError_clone(&*owner->contents.err);
6518 }
6519 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6520         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6521         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6522         uint32_t ret_ref = 0;
6523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6526         ret_ref = (uintptr_t)ret_var.inner;
6527         if (ret_var.is_owned) {
6528                 ret_ref |= 1;
6529         }
6530         return ret_ref;
6531 }
6532
6533 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6534         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6535         switch(obj->tag) {
6536                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6537                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6538                 default: abort();
6539         }
6540 }
6541 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6542         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6543         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6544                         LDKCVec_NetAddressZ some_var = obj->some;
6545                         uint32_tArray some_arr = NULL;
6546                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6547                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6548                         for (size_t m = 0; m < some_var.datalen; m++) {
6549                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6550                                 some_arr_ptr[m] = some_conv_12_ref;
6551                         }
6552                         
6553         return some_arr;
6554 }
6555 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6556 CHECK(owner->result_ok);
6557         return NetAddress_clone(&*owner->contents.result);
6558 }
6559 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6560         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6561         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6562         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6563         uint32_t ret_ref = (uintptr_t)ret_copy;
6564         return ret_ref;
6565 }
6566
6567 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6568 CHECK(!owner->result_ok);
6569         return DecodeError_clone(&*owner->contents.err);
6570 }
6571 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6572         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6573         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6574         uint32_t ret_ref = 0;
6575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6578         ret_ref = (uintptr_t)ret_var.inner;
6579         if (ret_var.is_owned) {
6580                 ret_ref |= 1;
6581         }
6582         return ret_ref;
6583 }
6584
6585 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6586         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6587         for (size_t i = 0; i < ret.datalen; i++) {
6588                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6589         }
6590         return ret;
6591 }
6592 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6593         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6594         for (size_t i = 0; i < ret.datalen; i++) {
6595                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6596         }
6597         return ret;
6598 }
6599 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6600         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6601         for (size_t i = 0; i < ret.datalen; i++) {
6602                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6603         }
6604         return ret;
6605 }
6606 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6607         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6608         for (size_t i = 0; i < ret.datalen; i++) {
6609                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6610         }
6611         return ret;
6612 }
6613 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6614 CHECK(owner->result_ok);
6615         return AcceptChannel_clone(&*owner->contents.result);
6616 }
6617 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6618         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6619         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6620         uint32_t ret_ref = 0;
6621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6624         ret_ref = (uintptr_t)ret_var.inner;
6625         if (ret_var.is_owned) {
6626                 ret_ref |= 1;
6627         }
6628         return ret_ref;
6629 }
6630
6631 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6632 CHECK(!owner->result_ok);
6633         return DecodeError_clone(&*owner->contents.err);
6634 }
6635 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6636         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6637         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6638         uint32_t ret_ref = 0;
6639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6642         ret_ref = (uintptr_t)ret_var.inner;
6643         if (ret_var.is_owned) {
6644                 ret_ref |= 1;
6645         }
6646         return ret_ref;
6647 }
6648
6649 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6650 CHECK(owner->result_ok);
6651         return AnnouncementSignatures_clone(&*owner->contents.result);
6652 }
6653 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6654         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6655         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6656         uint32_t ret_ref = 0;
6657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6660         ret_ref = (uintptr_t)ret_var.inner;
6661         if (ret_var.is_owned) {
6662                 ret_ref |= 1;
6663         }
6664         return ret_ref;
6665 }
6666
6667 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6668 CHECK(!owner->result_ok);
6669         return DecodeError_clone(&*owner->contents.err);
6670 }
6671 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6672         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6673         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6674         uint32_t ret_ref = 0;
6675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6678         ret_ref = (uintptr_t)ret_var.inner;
6679         if (ret_var.is_owned) {
6680                 ret_ref |= 1;
6681         }
6682         return ret_ref;
6683 }
6684
6685 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6686 CHECK(owner->result_ok);
6687         return ChannelReestablish_clone(&*owner->contents.result);
6688 }
6689 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6690         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6691         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6692         uint32_t ret_ref = 0;
6693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6696         ret_ref = (uintptr_t)ret_var.inner;
6697         if (ret_var.is_owned) {
6698                 ret_ref |= 1;
6699         }
6700         return ret_ref;
6701 }
6702
6703 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6704 CHECK(!owner->result_ok);
6705         return DecodeError_clone(&*owner->contents.err);
6706 }
6707 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6708         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6709         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6710         uint32_t ret_ref = 0;
6711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6714         ret_ref = (uintptr_t)ret_var.inner;
6715         if (ret_var.is_owned) {
6716                 ret_ref |= 1;
6717         }
6718         return ret_ref;
6719 }
6720
6721 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6722 CHECK(owner->result_ok);
6723         return ClosingSigned_clone(&*owner->contents.result);
6724 }
6725 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6726         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6727         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6728         uint32_t ret_ref = 0;
6729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6732         ret_ref = (uintptr_t)ret_var.inner;
6733         if (ret_var.is_owned) {
6734                 ret_ref |= 1;
6735         }
6736         return ret_ref;
6737 }
6738
6739 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6740 CHECK(!owner->result_ok);
6741         return DecodeError_clone(&*owner->contents.err);
6742 }
6743 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6744         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6745         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6746         uint32_t ret_ref = 0;
6747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6750         ret_ref = (uintptr_t)ret_var.inner;
6751         if (ret_var.is_owned) {
6752                 ret_ref |= 1;
6753         }
6754         return ret_ref;
6755 }
6756
6757 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6758 CHECK(owner->result_ok);
6759         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6760 }
6761 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6762         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6763         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6764         uint32_t ret_ref = 0;
6765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6768         ret_ref = (uintptr_t)ret_var.inner;
6769         if (ret_var.is_owned) {
6770                 ret_ref |= 1;
6771         }
6772         return ret_ref;
6773 }
6774
6775 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6776 CHECK(!owner->result_ok);
6777         return DecodeError_clone(&*owner->contents.err);
6778 }
6779 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6780         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6781         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6782         uint32_t ret_ref = 0;
6783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6786         ret_ref = (uintptr_t)ret_var.inner;
6787         if (ret_var.is_owned) {
6788                 ret_ref |= 1;
6789         }
6790         return ret_ref;
6791 }
6792
6793 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6794 CHECK(owner->result_ok);
6795         return CommitmentSigned_clone(&*owner->contents.result);
6796 }
6797 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6798         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6799         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6800         uint32_t ret_ref = 0;
6801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6804         ret_ref = (uintptr_t)ret_var.inner;
6805         if (ret_var.is_owned) {
6806                 ret_ref |= 1;
6807         }
6808         return ret_ref;
6809 }
6810
6811 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6812 CHECK(!owner->result_ok);
6813         return DecodeError_clone(&*owner->contents.err);
6814 }
6815 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6816         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6817         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6818         uint32_t ret_ref = 0;
6819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6822         ret_ref = (uintptr_t)ret_var.inner;
6823         if (ret_var.is_owned) {
6824                 ret_ref |= 1;
6825         }
6826         return ret_ref;
6827 }
6828
6829 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6830 CHECK(owner->result_ok);
6831         return FundingCreated_clone(&*owner->contents.result);
6832 }
6833 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6834         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6835         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6836         uint32_t ret_ref = 0;
6837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6840         ret_ref = (uintptr_t)ret_var.inner;
6841         if (ret_var.is_owned) {
6842                 ret_ref |= 1;
6843         }
6844         return ret_ref;
6845 }
6846
6847 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6848 CHECK(!owner->result_ok);
6849         return DecodeError_clone(&*owner->contents.err);
6850 }
6851 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6852         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6853         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6854         uint32_t ret_ref = 0;
6855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6858         ret_ref = (uintptr_t)ret_var.inner;
6859         if (ret_var.is_owned) {
6860                 ret_ref |= 1;
6861         }
6862         return ret_ref;
6863 }
6864
6865 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6866 CHECK(owner->result_ok);
6867         return FundingSigned_clone(&*owner->contents.result);
6868 }
6869 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6870         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6871         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6872         uint32_t ret_ref = 0;
6873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6876         ret_ref = (uintptr_t)ret_var.inner;
6877         if (ret_var.is_owned) {
6878                 ret_ref |= 1;
6879         }
6880         return ret_ref;
6881 }
6882
6883 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6884 CHECK(!owner->result_ok);
6885         return DecodeError_clone(&*owner->contents.err);
6886 }
6887 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6888         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6889         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6890         uint32_t ret_ref = 0;
6891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6894         ret_ref = (uintptr_t)ret_var.inner;
6895         if (ret_var.is_owned) {
6896                 ret_ref |= 1;
6897         }
6898         return ret_ref;
6899 }
6900
6901 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6902 CHECK(owner->result_ok);
6903         return FundingLocked_clone(&*owner->contents.result);
6904 }
6905 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6906         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6907         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6908         uint32_t ret_ref = 0;
6909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6912         ret_ref = (uintptr_t)ret_var.inner;
6913         if (ret_var.is_owned) {
6914                 ret_ref |= 1;
6915         }
6916         return ret_ref;
6917 }
6918
6919 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6920 CHECK(!owner->result_ok);
6921         return DecodeError_clone(&*owner->contents.err);
6922 }
6923 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6924         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6925         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6926         uint32_t ret_ref = 0;
6927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6930         ret_ref = (uintptr_t)ret_var.inner;
6931         if (ret_var.is_owned) {
6932                 ret_ref |= 1;
6933         }
6934         return ret_ref;
6935 }
6936
6937 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6938 CHECK(owner->result_ok);
6939         return Init_clone(&*owner->contents.result);
6940 }
6941 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6942         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6943         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6944         uint32_t ret_ref = 0;
6945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6948         ret_ref = (uintptr_t)ret_var.inner;
6949         if (ret_var.is_owned) {
6950                 ret_ref |= 1;
6951         }
6952         return ret_ref;
6953 }
6954
6955 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6956 CHECK(!owner->result_ok);
6957         return DecodeError_clone(&*owner->contents.err);
6958 }
6959 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
6960         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6961         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
6962         uint32_t ret_ref = 0;
6963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6966         ret_ref = (uintptr_t)ret_var.inner;
6967         if (ret_var.is_owned) {
6968                 ret_ref |= 1;
6969         }
6970         return ret_ref;
6971 }
6972
6973 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6974 CHECK(owner->result_ok);
6975         return OpenChannel_clone(&*owner->contents.result);
6976 }
6977 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
6978         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6979         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
6980         uint32_t ret_ref = 0;
6981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6984         ret_ref = (uintptr_t)ret_var.inner;
6985         if (ret_var.is_owned) {
6986                 ret_ref |= 1;
6987         }
6988         return ret_ref;
6989 }
6990
6991 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6992 CHECK(!owner->result_ok);
6993         return DecodeError_clone(&*owner->contents.err);
6994 }
6995 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
6996         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6997         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
6998         uint32_t ret_ref = 0;
6999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7002         ret_ref = (uintptr_t)ret_var.inner;
7003         if (ret_var.is_owned) {
7004                 ret_ref |= 1;
7005         }
7006         return ret_ref;
7007 }
7008
7009 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7010 CHECK(owner->result_ok);
7011         return RevokeAndACK_clone(&*owner->contents.result);
7012 }
7013 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7014         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7015         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7016         uint32_t ret_ref = 0;
7017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7020         ret_ref = (uintptr_t)ret_var.inner;
7021         if (ret_var.is_owned) {
7022                 ret_ref |= 1;
7023         }
7024         return ret_ref;
7025 }
7026
7027 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7028 CHECK(!owner->result_ok);
7029         return DecodeError_clone(&*owner->contents.err);
7030 }
7031 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7032         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7033         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7034         uint32_t ret_ref = 0;
7035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7038         ret_ref = (uintptr_t)ret_var.inner;
7039         if (ret_var.is_owned) {
7040                 ret_ref |= 1;
7041         }
7042         return ret_ref;
7043 }
7044
7045 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7046 CHECK(owner->result_ok);
7047         return Shutdown_clone(&*owner->contents.result);
7048 }
7049 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7050         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7051         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7052         uint32_t ret_ref = 0;
7053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7056         ret_ref = (uintptr_t)ret_var.inner;
7057         if (ret_var.is_owned) {
7058                 ret_ref |= 1;
7059         }
7060         return ret_ref;
7061 }
7062
7063 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7064 CHECK(!owner->result_ok);
7065         return DecodeError_clone(&*owner->contents.err);
7066 }
7067 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7068         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7069         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7070         uint32_t ret_ref = 0;
7071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7074         ret_ref = (uintptr_t)ret_var.inner;
7075         if (ret_var.is_owned) {
7076                 ret_ref |= 1;
7077         }
7078         return ret_ref;
7079 }
7080
7081 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7082 CHECK(owner->result_ok);
7083         return UpdateFailHTLC_clone(&*owner->contents.result);
7084 }
7085 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7086         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7087         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7088         uint32_t ret_ref = 0;
7089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7092         ret_ref = (uintptr_t)ret_var.inner;
7093         if (ret_var.is_owned) {
7094                 ret_ref |= 1;
7095         }
7096         return ret_ref;
7097 }
7098
7099 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7100 CHECK(!owner->result_ok);
7101         return DecodeError_clone(&*owner->contents.err);
7102 }
7103 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7104         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7105         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7106         uint32_t ret_ref = 0;
7107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7110         ret_ref = (uintptr_t)ret_var.inner;
7111         if (ret_var.is_owned) {
7112                 ret_ref |= 1;
7113         }
7114         return ret_ref;
7115 }
7116
7117 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7118 CHECK(owner->result_ok);
7119         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7120 }
7121 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7122         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7123         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7124         uint32_t ret_ref = 0;
7125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7128         ret_ref = (uintptr_t)ret_var.inner;
7129         if (ret_var.is_owned) {
7130                 ret_ref |= 1;
7131         }
7132         return ret_ref;
7133 }
7134
7135 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7136 CHECK(!owner->result_ok);
7137         return DecodeError_clone(&*owner->contents.err);
7138 }
7139 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7140         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7141         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7142         uint32_t ret_ref = 0;
7143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7146         ret_ref = (uintptr_t)ret_var.inner;
7147         if (ret_var.is_owned) {
7148                 ret_ref |= 1;
7149         }
7150         return ret_ref;
7151 }
7152
7153 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7154 CHECK(owner->result_ok);
7155         return UpdateFee_clone(&*owner->contents.result);
7156 }
7157 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7158         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7159         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7160         uint32_t ret_ref = 0;
7161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7164         ret_ref = (uintptr_t)ret_var.inner;
7165         if (ret_var.is_owned) {
7166                 ret_ref |= 1;
7167         }
7168         return ret_ref;
7169 }
7170
7171 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7172 CHECK(!owner->result_ok);
7173         return DecodeError_clone(&*owner->contents.err);
7174 }
7175 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7176         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7177         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7178         uint32_t ret_ref = 0;
7179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7182         ret_ref = (uintptr_t)ret_var.inner;
7183         if (ret_var.is_owned) {
7184                 ret_ref |= 1;
7185         }
7186         return ret_ref;
7187 }
7188
7189 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7190 CHECK(owner->result_ok);
7191         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7192 }
7193 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7194         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7195         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7196         uint32_t ret_ref = 0;
7197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7200         ret_ref = (uintptr_t)ret_var.inner;
7201         if (ret_var.is_owned) {
7202                 ret_ref |= 1;
7203         }
7204         return ret_ref;
7205 }
7206
7207 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7208 CHECK(!owner->result_ok);
7209         return DecodeError_clone(&*owner->contents.err);
7210 }
7211 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7212         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7213         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7214         uint32_t ret_ref = 0;
7215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7218         ret_ref = (uintptr_t)ret_var.inner;
7219         if (ret_var.is_owned) {
7220                 ret_ref |= 1;
7221         }
7222         return ret_ref;
7223 }
7224
7225 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7226 CHECK(owner->result_ok);
7227         return UpdateAddHTLC_clone(&*owner->contents.result);
7228 }
7229 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7230         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7231         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7232         uint32_t ret_ref = 0;
7233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7236         ret_ref = (uintptr_t)ret_var.inner;
7237         if (ret_var.is_owned) {
7238                 ret_ref |= 1;
7239         }
7240         return ret_ref;
7241 }
7242
7243 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7244 CHECK(!owner->result_ok);
7245         return DecodeError_clone(&*owner->contents.err);
7246 }
7247 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7248         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7249         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7250         uint32_t ret_ref = 0;
7251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7254         ret_ref = (uintptr_t)ret_var.inner;
7255         if (ret_var.is_owned) {
7256                 ret_ref |= 1;
7257         }
7258         return ret_ref;
7259 }
7260
7261 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7262 CHECK(owner->result_ok);
7263         return Ping_clone(&*owner->contents.result);
7264 }
7265 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7266         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7267         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7268         uint32_t ret_ref = 0;
7269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7272         ret_ref = (uintptr_t)ret_var.inner;
7273         if (ret_var.is_owned) {
7274                 ret_ref |= 1;
7275         }
7276         return ret_ref;
7277 }
7278
7279 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7280 CHECK(!owner->result_ok);
7281         return DecodeError_clone(&*owner->contents.err);
7282 }
7283 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7284         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7285         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7286         uint32_t ret_ref = 0;
7287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7290         ret_ref = (uintptr_t)ret_var.inner;
7291         if (ret_var.is_owned) {
7292                 ret_ref |= 1;
7293         }
7294         return ret_ref;
7295 }
7296
7297 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7298 CHECK(owner->result_ok);
7299         return Pong_clone(&*owner->contents.result);
7300 }
7301 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7302         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7303         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7304         uint32_t ret_ref = 0;
7305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7308         ret_ref = (uintptr_t)ret_var.inner;
7309         if (ret_var.is_owned) {
7310                 ret_ref |= 1;
7311         }
7312         return ret_ref;
7313 }
7314
7315 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7316 CHECK(!owner->result_ok);
7317         return DecodeError_clone(&*owner->contents.err);
7318 }
7319 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7320         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7321         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7322         uint32_t ret_ref = 0;
7323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7326         ret_ref = (uintptr_t)ret_var.inner;
7327         if (ret_var.is_owned) {
7328                 ret_ref |= 1;
7329         }
7330         return ret_ref;
7331 }
7332
7333 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7334 CHECK(owner->result_ok);
7335         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7336 }
7337 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7338         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7339         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7340         uint32_t ret_ref = 0;
7341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7344         ret_ref = (uintptr_t)ret_var.inner;
7345         if (ret_var.is_owned) {
7346                 ret_ref |= 1;
7347         }
7348         return ret_ref;
7349 }
7350
7351 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7352 CHECK(!owner->result_ok);
7353         return DecodeError_clone(&*owner->contents.err);
7354 }
7355 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7356         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7357         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7358         uint32_t ret_ref = 0;
7359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7362         ret_ref = (uintptr_t)ret_var.inner;
7363         if (ret_var.is_owned) {
7364                 ret_ref |= 1;
7365         }
7366         return ret_ref;
7367 }
7368
7369 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7370 CHECK(owner->result_ok);
7371         return ChannelAnnouncement_clone(&*owner->contents.result);
7372 }
7373 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7374         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7375         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7376         uint32_t ret_ref = 0;
7377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7380         ret_ref = (uintptr_t)ret_var.inner;
7381         if (ret_var.is_owned) {
7382                 ret_ref |= 1;
7383         }
7384         return ret_ref;
7385 }
7386
7387 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7388 CHECK(!owner->result_ok);
7389         return DecodeError_clone(&*owner->contents.err);
7390 }
7391 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7392         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7393         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7394         uint32_t ret_ref = 0;
7395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7398         ret_ref = (uintptr_t)ret_var.inner;
7399         if (ret_var.is_owned) {
7400                 ret_ref |= 1;
7401         }
7402         return ret_ref;
7403 }
7404
7405 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7406 CHECK(owner->result_ok);
7407         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7408 }
7409 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7410         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7411         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7412         uint32_t ret_ref = 0;
7413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7416         ret_ref = (uintptr_t)ret_var.inner;
7417         if (ret_var.is_owned) {
7418                 ret_ref |= 1;
7419         }
7420         return ret_ref;
7421 }
7422
7423 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7424 CHECK(!owner->result_ok);
7425         return DecodeError_clone(&*owner->contents.err);
7426 }
7427 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7428         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7429         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7430         uint32_t ret_ref = 0;
7431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7434         ret_ref = (uintptr_t)ret_var.inner;
7435         if (ret_var.is_owned) {
7436                 ret_ref |= 1;
7437         }
7438         return ret_ref;
7439 }
7440
7441 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7442 CHECK(owner->result_ok);
7443         return ChannelUpdate_clone(&*owner->contents.result);
7444 }
7445 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7446         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7447         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7448         uint32_t ret_ref = 0;
7449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7452         ret_ref = (uintptr_t)ret_var.inner;
7453         if (ret_var.is_owned) {
7454                 ret_ref |= 1;
7455         }
7456         return ret_ref;
7457 }
7458
7459 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7460 CHECK(!owner->result_ok);
7461         return DecodeError_clone(&*owner->contents.err);
7462 }
7463 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7464         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7465         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7466         uint32_t ret_ref = 0;
7467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7470         ret_ref = (uintptr_t)ret_var.inner;
7471         if (ret_var.is_owned) {
7472                 ret_ref |= 1;
7473         }
7474         return ret_ref;
7475 }
7476
7477 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7478 CHECK(owner->result_ok);
7479         return ErrorMessage_clone(&*owner->contents.result);
7480 }
7481 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7482         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7483         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7484         uint32_t ret_ref = 0;
7485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7488         ret_ref = (uintptr_t)ret_var.inner;
7489         if (ret_var.is_owned) {
7490                 ret_ref |= 1;
7491         }
7492         return ret_ref;
7493 }
7494
7495 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7496 CHECK(!owner->result_ok);
7497         return DecodeError_clone(&*owner->contents.err);
7498 }
7499 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7500         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7501         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7502         uint32_t ret_ref = 0;
7503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7506         ret_ref = (uintptr_t)ret_var.inner;
7507         if (ret_var.is_owned) {
7508                 ret_ref |= 1;
7509         }
7510         return ret_ref;
7511 }
7512
7513 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7514 CHECK(owner->result_ok);
7515         return WarningMessage_clone(&*owner->contents.result);
7516 }
7517 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7518         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7519         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7520         uint32_t ret_ref = 0;
7521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7524         ret_ref = (uintptr_t)ret_var.inner;
7525         if (ret_var.is_owned) {
7526                 ret_ref |= 1;
7527         }
7528         return ret_ref;
7529 }
7530
7531 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7532 CHECK(!owner->result_ok);
7533         return DecodeError_clone(&*owner->contents.err);
7534 }
7535 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7536         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7537         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7538         uint32_t ret_ref = 0;
7539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7542         ret_ref = (uintptr_t)ret_var.inner;
7543         if (ret_var.is_owned) {
7544                 ret_ref |= 1;
7545         }
7546         return ret_ref;
7547 }
7548
7549 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7550 CHECK(owner->result_ok);
7551         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7552 }
7553 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7554         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7555         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7556         uint32_t ret_ref = 0;
7557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7560         ret_ref = (uintptr_t)ret_var.inner;
7561         if (ret_var.is_owned) {
7562                 ret_ref |= 1;
7563         }
7564         return ret_ref;
7565 }
7566
7567 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7568 CHECK(!owner->result_ok);
7569         return DecodeError_clone(&*owner->contents.err);
7570 }
7571 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7572         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7573         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7574         uint32_t ret_ref = 0;
7575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7578         ret_ref = (uintptr_t)ret_var.inner;
7579         if (ret_var.is_owned) {
7580                 ret_ref |= 1;
7581         }
7582         return ret_ref;
7583 }
7584
7585 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7586 CHECK(owner->result_ok);
7587         return NodeAnnouncement_clone(&*owner->contents.result);
7588 }
7589 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7590         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7591         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7592         uint32_t ret_ref = 0;
7593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7596         ret_ref = (uintptr_t)ret_var.inner;
7597         if (ret_var.is_owned) {
7598                 ret_ref |= 1;
7599         }
7600         return ret_ref;
7601 }
7602
7603 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7604 CHECK(!owner->result_ok);
7605         return DecodeError_clone(&*owner->contents.err);
7606 }
7607 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7608         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7609         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7610         uint32_t ret_ref = 0;
7611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7614         ret_ref = (uintptr_t)ret_var.inner;
7615         if (ret_var.is_owned) {
7616                 ret_ref |= 1;
7617         }
7618         return ret_ref;
7619 }
7620
7621 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7622 CHECK(owner->result_ok);
7623         return QueryShortChannelIds_clone(&*owner->contents.result);
7624 }
7625 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7626         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7627         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7628         uint32_t ret_ref = 0;
7629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7632         ret_ref = (uintptr_t)ret_var.inner;
7633         if (ret_var.is_owned) {
7634                 ret_ref |= 1;
7635         }
7636         return ret_ref;
7637 }
7638
7639 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7640 CHECK(!owner->result_ok);
7641         return DecodeError_clone(&*owner->contents.err);
7642 }
7643 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7644         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7645         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7646         uint32_t ret_ref = 0;
7647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7650         ret_ref = (uintptr_t)ret_var.inner;
7651         if (ret_var.is_owned) {
7652                 ret_ref |= 1;
7653         }
7654         return ret_ref;
7655 }
7656
7657 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7658 CHECK(owner->result_ok);
7659         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7660 }
7661 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7662         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7663         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7664         uint32_t ret_ref = 0;
7665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7668         ret_ref = (uintptr_t)ret_var.inner;
7669         if (ret_var.is_owned) {
7670                 ret_ref |= 1;
7671         }
7672         return ret_ref;
7673 }
7674
7675 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7676 CHECK(!owner->result_ok);
7677         return DecodeError_clone(&*owner->contents.err);
7678 }
7679 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7680         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7681         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7682         uint32_t ret_ref = 0;
7683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7686         ret_ref = (uintptr_t)ret_var.inner;
7687         if (ret_var.is_owned) {
7688                 ret_ref |= 1;
7689         }
7690         return ret_ref;
7691 }
7692
7693 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7694 CHECK(owner->result_ok);
7695         return QueryChannelRange_clone(&*owner->contents.result);
7696 }
7697 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7698         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7699         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7700         uint32_t ret_ref = 0;
7701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7704         ret_ref = (uintptr_t)ret_var.inner;
7705         if (ret_var.is_owned) {
7706                 ret_ref |= 1;
7707         }
7708         return ret_ref;
7709 }
7710
7711 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7712 CHECK(!owner->result_ok);
7713         return DecodeError_clone(&*owner->contents.err);
7714 }
7715 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7716         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7717         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7718         uint32_t ret_ref = 0;
7719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7722         ret_ref = (uintptr_t)ret_var.inner;
7723         if (ret_var.is_owned) {
7724                 ret_ref |= 1;
7725         }
7726         return ret_ref;
7727 }
7728
7729 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7730 CHECK(owner->result_ok);
7731         return ReplyChannelRange_clone(&*owner->contents.result);
7732 }
7733 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7734         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7735         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7736         uint32_t ret_ref = 0;
7737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7740         ret_ref = (uintptr_t)ret_var.inner;
7741         if (ret_var.is_owned) {
7742                 ret_ref |= 1;
7743         }
7744         return ret_ref;
7745 }
7746
7747 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7748 CHECK(!owner->result_ok);
7749         return DecodeError_clone(&*owner->contents.err);
7750 }
7751 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7752         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7753         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7754         uint32_t ret_ref = 0;
7755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7758         ret_ref = (uintptr_t)ret_var.inner;
7759         if (ret_var.is_owned) {
7760                 ret_ref |= 1;
7761         }
7762         return ret_ref;
7763 }
7764
7765 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7766 CHECK(owner->result_ok);
7767         return GossipTimestampFilter_clone(&*owner->contents.result);
7768 }
7769 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7770         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7771         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7772         uint32_t ret_ref = 0;
7773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7776         ret_ref = (uintptr_t)ret_var.inner;
7777         if (ret_var.is_owned) {
7778                 ret_ref |= 1;
7779         }
7780         return ret_ref;
7781 }
7782
7783 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7784 CHECK(!owner->result_ok);
7785         return DecodeError_clone(&*owner->contents.err);
7786 }
7787 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7788         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7789         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7790         uint32_t ret_ref = 0;
7791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7794         ret_ref = (uintptr_t)ret_var.inner;
7795         if (ret_var.is_owned) {
7796                 ret_ref |= 1;
7797         }
7798         return ret_ref;
7799 }
7800
7801 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7802         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7803         switch(obj->tag) {
7804                 case LDKSignOrCreationError_SignError: return 0;
7805                 case LDKSignOrCreationError_CreationError: return 1;
7806                 default: abort();
7807         }
7808 }
7809 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7810         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7811         assert(obj->tag == LDKSignOrCreationError_CreationError);
7812                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7813         return creation_error_conv;
7814 }
7815 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7816 CHECK(owner->result_ok);
7817         return Invoice_clone(&*owner->contents.result);
7818 }
7819 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7820         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7821         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7822         uint32_t ret_ref = 0;
7823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7826         ret_ref = (uintptr_t)ret_var.inner;
7827         if (ret_var.is_owned) {
7828                 ret_ref |= 1;
7829         }
7830         return ret_ref;
7831 }
7832
7833 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7834 CHECK(!owner->result_ok);
7835         return SignOrCreationError_clone(&*owner->contents.err);
7836 }
7837 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7838         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7839         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7840         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7841         uint32_t ret_ref = (uintptr_t)ret_copy;
7842         return ret_ref;
7843 }
7844
7845 typedef struct LDKFilter_JCalls {
7846         atomic_size_t refcnt;
7847         uint32_t instance_ptr;
7848 } LDKFilter_JCalls;
7849 static void LDKFilter_JCalls_free(void* this_arg) {
7850         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7851         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7852                 FREE(j_calls);
7853         }
7854 }
7855 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7856         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7857         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7858         memcpy(txid_arr->elems, *txid, 32);
7859         LDKu8slice script_pubkey_var = script_pubkey;
7860         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7861         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7862         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7863 }
7864 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7865         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7866         LDKWatchedOutput output_var = output;
7867         uint32_t output_ref = 0;
7868         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7869         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7870         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7871         output_ref = (uintptr_t)output_var.inner;
7872         if (output_var.is_owned) {
7873                 output_ref |= 1;
7874         }
7875         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7876         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7877         CHECK_ACCESS(ret_ptr);
7878         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7879         FREE((void*)ret);
7880         return ret_conv;
7881 }
7882 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7883         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7884         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7885 }
7886 static inline LDKFilter LDKFilter_init (JSValue o) {
7887         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7888         atomic_init(&calls->refcnt, 1);
7889         calls->instance_ptr = o;
7890
7891         LDKFilter ret = {
7892                 .this_arg = (void*) calls,
7893                 .register_tx = register_tx_LDKFilter_jcall,
7894                 .register_output = register_output_LDKFilter_jcall,
7895                 .free = LDKFilter_JCalls_free,
7896         };
7897         return ret;
7898 }
7899 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7900         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7901         *res_ptr = LDKFilter_init(o);
7902         return (long)res_ptr;
7903 }
7904 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7905         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7906         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7907         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7908         unsigned char txid_arr[32];
7909         CHECK(txid->arr_len == 32);
7910         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7911         unsigned char (*txid_ref)[32] = &txid_arr;
7912         LDKu8slice script_pubkey_ref;
7913         script_pubkey_ref.datalen = script_pubkey->arr_len;
7914         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7915         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7916 }
7917
7918 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7919         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7920         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7921         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7922         LDKWatchedOutput output_conv;
7923         output_conv.inner = (void*)(output & (~1));
7924         output_conv.is_owned = (output & 1) || (output == 0);
7925         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7926         output_conv = WatchedOutput_clone(&output_conv);
7927         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7928         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7929         uint32_t ret_ref = (uintptr_t)ret_copy;
7930         return ret_ref;
7931 }
7932
7933 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7934         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7935         switch(obj->tag) {
7936                 case LDKCOption_FilterZ_Some: return 0;
7937                 case LDKCOption_FilterZ_None: return 1;
7938                 default: abort();
7939         }
7940 }
7941 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7942         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7943         assert(obj->tag == LDKCOption_FilterZ_Some);
7944                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7945                         *some_ret = obj->some;
7946                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7947                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7948                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7949                                 LDKFilter_JCalls_cloned(&(*some_ret));
7950                         }
7951         return (uint32_t)some_ret;
7952 }
7953 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7954 CHECK(owner->result_ok);
7955         return &*owner->contents.result;
7956 }
7957 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
7958         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7959         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7960         uint32_t ret_ref = 0;
7961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7964         ret_ref = (uintptr_t)ret_var.inner & ~1;
7965         return ret_ref;
7966 }
7967
7968 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7969 CHECK(!owner->result_ok);
7970         return *owner->contents.err;
7971 }
7972 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
7973         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7974         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7975 }
7976
7977 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7978         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7979         for (size_t i = 0; i < ret.datalen; i++) {
7980                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7981         }
7982         return ret;
7983 }
7984 typedef struct LDKMessageSendEventsProvider_JCalls {
7985         atomic_size_t refcnt;
7986         uint32_t instance_ptr;
7987 } LDKMessageSendEventsProvider_JCalls;
7988 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7989         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7990         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7991                 FREE(j_calls);
7992         }
7993 }
7994 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7995         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7996         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
7997         LDKCVec_MessageSendEventZ ret_constr;
7998         ret_constr.datalen = ret->arr_len;
7999         if (ret_constr.datalen > 0)
8000                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8001         else
8002                 ret_constr.data = NULL;
8003         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8004         for (size_t s = 0; s < ret_constr.datalen; s++) {
8005                 uint32_t ret_conv_18 = ret_vals[s];
8006                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8007                 CHECK_ACCESS(ret_conv_18_ptr);
8008                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8009                 FREE((void*)ret_conv_18);
8010                 ret_constr.data[s] = ret_conv_18_conv;
8011         }
8012         return ret_constr;
8013 }
8014 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8015         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8016         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8017 }
8018 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8019         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8020         atomic_init(&calls->refcnt, 1);
8021         calls->instance_ptr = o;
8022
8023         LDKMessageSendEventsProvider ret = {
8024                 .this_arg = (void*) calls,
8025                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8026                 .free = LDKMessageSendEventsProvider_JCalls_free,
8027         };
8028         return ret;
8029 }
8030 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8031         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8032         *res_ptr = LDKMessageSendEventsProvider_init(o);
8033         return (long)res_ptr;
8034 }
8035 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) {
8036         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8037         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8038         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8039         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8040         uint32_tArray ret_arr = NULL;
8041         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8042         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8043         for (size_t s = 0; s < ret_var.datalen; s++) {
8044                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8045                 *ret_conv_18_copy = ret_var.data[s];
8046                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8047                 ret_arr_ptr[s] = ret_conv_18_ref;
8048         }
8049         
8050         FREE(ret_var.data);
8051         return ret_arr;
8052 }
8053
8054 typedef struct LDKEventHandler_JCalls {
8055         atomic_size_t refcnt;
8056         uint32_t instance_ptr;
8057 } LDKEventHandler_JCalls;
8058 static void LDKEventHandler_JCalls_free(void* this_arg) {
8059         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8060         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8061                 FREE(j_calls);
8062         }
8063 }
8064 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8065         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8066         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8067         *ret_event = Event_clone(event);
8068         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8069 }
8070 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8071         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8072         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8073 }
8074 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8075         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8076         atomic_init(&calls->refcnt, 1);
8077         calls->instance_ptr = o;
8078
8079         LDKEventHandler ret = {
8080                 .this_arg = (void*) calls,
8081                 .handle_event = handle_event_LDKEventHandler_jcall,
8082                 .free = LDKEventHandler_JCalls_free,
8083         };
8084         return ret;
8085 }
8086 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8087         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8088         *res_ptr = LDKEventHandler_init(o);
8089         return (long)res_ptr;
8090 }
8091 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8092         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8093         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8094         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8095         LDKEvent* event_conv = (LDKEvent*)event;
8096         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8097 }
8098
8099 typedef struct LDKEventsProvider_JCalls {
8100         atomic_size_t refcnt;
8101         uint32_t instance_ptr;
8102 } LDKEventsProvider_JCalls;
8103 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8104         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8105         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8106                 FREE(j_calls);
8107         }
8108 }
8109 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8110         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8111         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8112         *handler_ret = handler;
8113         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8114 }
8115 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8116         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8117         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8118 }
8119 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8120         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8121         atomic_init(&calls->refcnt, 1);
8122         calls->instance_ptr = o;
8123
8124         LDKEventsProvider ret = {
8125                 .this_arg = (void*) calls,
8126                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8127                 .free = LDKEventsProvider_JCalls_free,
8128         };
8129         return ret;
8130 }
8131 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8132         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8133         *res_ptr = LDKEventsProvider_init(o);
8134         return (long)res_ptr;
8135 }
8136 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8139         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8140         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8141         CHECK_ACCESS(handler_ptr);
8142         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8143         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8144                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8145                 LDKEventHandler_JCalls_cloned(&handler_conv);
8146         }
8147         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8148 }
8149
8150 typedef struct LDKListen_JCalls {
8151         atomic_size_t refcnt;
8152         uint32_t instance_ptr;
8153 } LDKListen_JCalls;
8154 static void LDKListen_JCalls_free(void* this_arg) {
8155         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8156         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8157                 FREE(j_calls);
8158         }
8159 }
8160 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8161         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8162         LDKu8slice block_var = block;
8163         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8164         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8165         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
8166 }
8167 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8168         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8169         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8170         memcpy(header_arr->elems, *header, 80);
8171         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
8172 }
8173 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8174         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8175         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8176 }
8177 static inline LDKListen LDKListen_init (JSValue o) {
8178         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8179         atomic_init(&calls->refcnt, 1);
8180         calls->instance_ptr = o;
8181
8182         LDKListen ret = {
8183                 .this_arg = (void*) calls,
8184                 .block_connected = block_connected_LDKListen_jcall,
8185                 .block_disconnected = block_disconnected_LDKListen_jcall,
8186                 .free = LDKListen_JCalls_free,
8187         };
8188         return ret;
8189 }
8190 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8191         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8192         *res_ptr = LDKListen_init(o);
8193         return (long)res_ptr;
8194 }
8195 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8196         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8198         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8199         LDKu8slice block_ref;
8200         block_ref.datalen = block->arr_len;
8201         block_ref.data = block->elems /* XXX block leaks */;
8202         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8203 }
8204
8205 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8206         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8207         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8208         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8209         unsigned char header_arr[80];
8210         CHECK(header->arr_len == 80);
8211         memcpy(header_arr, header->elems, 80); FREE(header);
8212         unsigned char (*header_ref)[80] = &header_arr;
8213         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8214 }
8215
8216 typedef struct LDKConfirm_JCalls {
8217         atomic_size_t refcnt;
8218         uint32_t instance_ptr;
8219 } LDKConfirm_JCalls;
8220 static void LDKConfirm_JCalls_free(void* this_arg) {
8221         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8222         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8223                 FREE(j_calls);
8224         }
8225 }
8226 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8227         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8228         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8229         memcpy(header_arr->elems, *header, 80);
8230         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8231         uint32_tArray txdata_arr = NULL;
8232         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8233         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8234         for (size_t c = 0; c < txdata_var.datalen; c++) {
8235                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8236                 *txdata_conv_28_conv = txdata_var.data[c];
8237                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8238         }
8239         
8240         FREE(txdata_var.data);
8241         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
8242 }
8243 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8244         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8245         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8246         memcpy(txid_arr->elems, *txid, 32);
8247         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8248 }
8249 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8250         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8251         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8252         memcpy(header_arr->elems, *header, 80);
8253         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
8254 }
8255 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8256         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8257         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8258         LDKCVec_TxidZ ret_constr;
8259         ret_constr.datalen = ret->arr_len;
8260         if (ret_constr.datalen > 0)
8261                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8262         else
8263                 ret_constr.data = NULL;
8264         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8265         for (size_t m = 0; m < ret_constr.datalen; m++) {
8266                 int8_tArray ret_conv_12 = ret_vals[m];
8267                 LDKThirtyTwoBytes ret_conv_12_ref;
8268                 CHECK(ret_conv_12->arr_len == 32);
8269                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8270                 ret_constr.data[m] = ret_conv_12_ref;
8271         }
8272         return ret_constr;
8273 }
8274 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8275         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8276         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8277 }
8278 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8279         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8280         atomic_init(&calls->refcnt, 1);
8281         calls->instance_ptr = o;
8282
8283         LDKConfirm ret = {
8284                 .this_arg = (void*) calls,
8285                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8286                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8287                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8288                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8289                 .free = LDKConfirm_JCalls_free,
8290         };
8291         return ret;
8292 }
8293 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8294         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8295         *res_ptr = LDKConfirm_init(o);
8296         return (long)res_ptr;
8297 }
8298 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) {
8299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8301         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8302         unsigned char header_arr[80];
8303         CHECK(header->arr_len == 80);
8304         memcpy(header_arr, header->elems, 80); FREE(header);
8305         unsigned char (*header_ref)[80] = &header_arr;
8306         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8307         txdata_constr.datalen = txdata->arr_len;
8308         if (txdata_constr.datalen > 0)
8309                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8310         else
8311                 txdata_constr.data = NULL;
8312         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8313         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8314                 uint32_t txdata_conv_28 = txdata_vals[c];
8315                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8316                 CHECK_ACCESS(txdata_conv_28_ptr);
8317                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8318                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8319                 txdata_constr.data[c] = txdata_conv_28_conv;
8320         }
8321         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8322 }
8323
8324 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8325         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8326         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8327         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8328         unsigned char txid_arr[32];
8329         CHECK(txid->arr_len == 32);
8330         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8331         unsigned char (*txid_ref)[32] = &txid_arr;
8332         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8333 }
8334
8335 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8336         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8337         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8338         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8339         unsigned char header_arr[80];
8340         CHECK(header->arr_len == 80);
8341         memcpy(header_arr, header->elems, 80); FREE(header);
8342         unsigned char (*header_ref)[80] = &header_arr;
8343         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8344 }
8345
8346 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8349         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8350         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8351         ptrArray ret_arr = NULL;
8352         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8353         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8354         for (size_t m = 0; m < ret_var.datalen; m++) {
8355                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8356                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8357                 ret_arr_ptr[m] = ret_conv_12_arr;
8358         }
8359         
8360         FREE(ret_var.data);
8361         return ret_arr;
8362 }
8363
8364 typedef struct LDKPersist_JCalls {
8365         atomic_size_t refcnt;
8366         uint32_t instance_ptr;
8367 } LDKPersist_JCalls;
8368 static void LDKPersist_JCalls_free(void* this_arg) {
8369         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8370         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8371                 FREE(j_calls);
8372         }
8373 }
8374 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8375         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8376         LDKOutPoint channel_id_var = channel_id;
8377         uint32_t channel_id_ref = 0;
8378         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8379         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8380         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8381         channel_id_ref = (uintptr_t)channel_id_var.inner;
8382         if (channel_id_var.is_owned) {
8383                 channel_id_ref |= 1;
8384         }
8385         LDKChannelMonitor data_var = *data;
8386         uint32_t data_ref = 0;
8387         data_var = ChannelMonitor_clone(&data_var);
8388         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8389         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8390         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8391         data_ref = (uintptr_t)data_var.inner;
8392         if (data_var.is_owned) {
8393                 data_ref |= 1;
8394         }
8395         LDKMonitorUpdateId update_id_var = update_id;
8396         uint32_t update_id_ref = 0;
8397         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8398         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8399         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8400         update_id_ref = (uintptr_t)update_id_var.inner;
8401         if (update_id_var.is_owned) {
8402                 update_id_ref |= 1;
8403         }
8404         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);
8405         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8406         CHECK_ACCESS(ret_ptr);
8407         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8408         FREE((void*)ret);
8409         return ret_conv;
8410 }
8411 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8412         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8413         LDKOutPoint channel_id_var = channel_id;
8414         uint32_t channel_id_ref = 0;
8415         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8416         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8417         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8418         channel_id_ref = (uintptr_t)channel_id_var.inner;
8419         if (channel_id_var.is_owned) {
8420                 channel_id_ref |= 1;
8421         }
8422         LDKChannelMonitorUpdate update_var = *update;
8423         uint32_t update_ref = 0;
8424         if ((uintptr_t)update_var.inner > 4096) {
8425                 update_var = ChannelMonitorUpdate_clone(&update_var);
8426                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8427                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8428         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8429                 update_ref = (uintptr_t)update_var.inner;
8430                 if (update_var.is_owned) {
8431                         update_ref |= 1;
8432                 }
8433         }
8434         LDKChannelMonitor data_var = *data;
8435         uint32_t data_ref = 0;
8436         data_var = ChannelMonitor_clone(&data_var);
8437         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8438         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8439         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8440         data_ref = (uintptr_t)data_var.inner;
8441         if (data_var.is_owned) {
8442                 data_ref |= 1;
8443         }
8444         LDKMonitorUpdateId update_id_var = update_id;
8445         uint32_t update_id_ref = 0;
8446         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8447         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8448         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8449         update_id_ref = (uintptr_t)update_id_var.inner;
8450         if (update_id_var.is_owned) {
8451                 update_id_ref |= 1;
8452         }
8453         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);
8454         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8455         CHECK_ACCESS(ret_ptr);
8456         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8457         FREE((void*)ret);
8458         return ret_conv;
8459 }
8460 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8461         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8462         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8463 }
8464 static inline LDKPersist LDKPersist_init (JSValue o) {
8465         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8466         atomic_init(&calls->refcnt, 1);
8467         calls->instance_ptr = o;
8468
8469         LDKPersist ret = {
8470                 .this_arg = (void*) calls,
8471                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8472                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8473                 .free = LDKPersist_JCalls_free,
8474         };
8475         return ret;
8476 }
8477 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8478         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8479         *res_ptr = LDKPersist_init(o);
8480         return (long)res_ptr;
8481 }
8482 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) {
8483         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8484         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8485         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8486         LDKOutPoint channel_id_conv;
8487         channel_id_conv.inner = (void*)(channel_id & (~1));
8488         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8489         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8490         channel_id_conv = OutPoint_clone(&channel_id_conv);
8491         LDKChannelMonitor data_conv;
8492         data_conv.inner = (void*)(data & (~1));
8493         data_conv.is_owned = false;
8494         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8495         LDKMonitorUpdateId update_id_conv;
8496         update_id_conv.inner = (void*)(update_id & (~1));
8497         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8498         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8499         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8500         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8501         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8502         return (uint32_t)ret_conv;
8503 }
8504
8505 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) {
8506         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8507         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8508         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8509         LDKOutPoint channel_id_conv;
8510         channel_id_conv.inner = (void*)(channel_id & (~1));
8511         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8512         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8513         channel_id_conv = OutPoint_clone(&channel_id_conv);
8514         LDKChannelMonitorUpdate update_conv;
8515         update_conv.inner = (void*)(update & (~1));
8516         update_conv.is_owned = false;
8517         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8518         LDKChannelMonitor data_conv;
8519         data_conv.inner = (void*)(data & (~1));
8520         data_conv.is_owned = false;
8521         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8522         LDKMonitorUpdateId update_id_conv;
8523         update_id_conv.inner = (void*)(update_id & (~1));
8524         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8525         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8526         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8527         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8528         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8529         return (uint32_t)ret_conv;
8530 }
8531
8532 typedef struct LDKChannelMessageHandler_JCalls {
8533         atomic_size_t refcnt;
8534         uint32_t instance_ptr;
8535         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8536 } LDKChannelMessageHandler_JCalls;
8537 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8539         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8540                 FREE(j_calls);
8541         }
8542 }
8543 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8545         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8546         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8547         LDKInitFeatures their_features_var = their_features;
8548         uint32_t their_features_ref = 0;
8549         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8550         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8551         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8552         their_features_ref = (uintptr_t)their_features_var.inner;
8553         if (their_features_var.is_owned) {
8554                 their_features_ref |= 1;
8555         }
8556         LDKOpenChannel msg_var = *msg;
8557         uint32_t msg_ref = 0;
8558         msg_var = OpenChannel_clone(&msg_var);
8559         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8560         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8561         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8562         msg_ref = (uintptr_t)msg_var.inner;
8563         if (msg_var.is_owned) {
8564                 msg_ref |= 1;
8565         }
8566         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8567 }
8568 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8569         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8570         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8571         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8572         LDKInitFeatures their_features_var = their_features;
8573         uint32_t their_features_ref = 0;
8574         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8575         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8576         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8577         their_features_ref = (uintptr_t)their_features_var.inner;
8578         if (their_features_var.is_owned) {
8579                 their_features_ref |= 1;
8580         }
8581         LDKAcceptChannel msg_var = *msg;
8582         uint32_t msg_ref = 0;
8583         msg_var = AcceptChannel_clone(&msg_var);
8584         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8585         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8587         msg_ref = (uintptr_t)msg_var.inner;
8588         if (msg_var.is_owned) {
8589                 msg_ref |= 1;
8590         }
8591         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8592 }
8593 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8594         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8595         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8596         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8597         LDKFundingCreated msg_var = *msg;
8598         uint32_t msg_ref = 0;
8599         msg_var = FundingCreated_clone(&msg_var);
8600         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8601         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8602         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8603         msg_ref = (uintptr_t)msg_var.inner;
8604         if (msg_var.is_owned) {
8605                 msg_ref |= 1;
8606         }
8607         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8608 }
8609 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8610         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8611         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8612         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8613         LDKFundingSigned msg_var = *msg;
8614         uint32_t msg_ref = 0;
8615         msg_var = FundingSigned_clone(&msg_var);
8616         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8617         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8618         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8619         msg_ref = (uintptr_t)msg_var.inner;
8620         if (msg_var.is_owned) {
8621                 msg_ref |= 1;
8622         }
8623         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8624 }
8625 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8626         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8627         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8628         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8629         LDKFundingLocked msg_var = *msg;
8630         uint32_t msg_ref = 0;
8631         msg_var = FundingLocked_clone(&msg_var);
8632         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8633         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8635         msg_ref = (uintptr_t)msg_var.inner;
8636         if (msg_var.is_owned) {
8637                 msg_ref |= 1;
8638         }
8639         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8640 }
8641 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8642         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8643         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8644         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8645         LDKInitFeatures their_features_var = *their_features;
8646         uint32_t their_features_ref = 0;
8647         their_features_var = InitFeatures_clone(&their_features_var);
8648         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8649         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8651         their_features_ref = (uintptr_t)their_features_var.inner;
8652         if (their_features_var.is_owned) {
8653                 their_features_ref |= 1;
8654         }
8655         LDKShutdown msg_var = *msg;
8656         uint32_t msg_ref = 0;
8657         msg_var = Shutdown_clone(&msg_var);
8658         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8659         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8661         msg_ref = (uintptr_t)msg_var.inner;
8662         if (msg_var.is_owned) {
8663                 msg_ref |= 1;
8664         }
8665         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8666 }
8667 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8669         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8670         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8671         LDKClosingSigned msg_var = *msg;
8672         uint32_t msg_ref = 0;
8673         msg_var = ClosingSigned_clone(&msg_var);
8674         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8675         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8677         msg_ref = (uintptr_t)msg_var.inner;
8678         if (msg_var.is_owned) {
8679                 msg_ref |= 1;
8680         }
8681         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8682 }
8683 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8684         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8685         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8686         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8687         LDKUpdateAddHTLC msg_var = *msg;
8688         uint32_t msg_ref = 0;
8689         msg_var = UpdateAddHTLC_clone(&msg_var);
8690         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8691         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8693         msg_ref = (uintptr_t)msg_var.inner;
8694         if (msg_var.is_owned) {
8695                 msg_ref |= 1;
8696         }
8697         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8698 }
8699 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8700         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8701         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8702         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8703         LDKUpdateFulfillHTLC msg_var = *msg;
8704         uint32_t msg_ref = 0;
8705         msg_var = UpdateFulfillHTLC_clone(&msg_var);
8706         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8707         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8709         msg_ref = (uintptr_t)msg_var.inner;
8710         if (msg_var.is_owned) {
8711                 msg_ref |= 1;
8712         }
8713         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8714 }
8715 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8717         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8718         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8719         LDKUpdateFailHTLC msg_var = *msg;
8720         uint32_t msg_ref = 0;
8721         msg_var = UpdateFailHTLC_clone(&msg_var);
8722         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8723         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8725         msg_ref = (uintptr_t)msg_var.inner;
8726         if (msg_var.is_owned) {
8727                 msg_ref |= 1;
8728         }
8729         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8730 }
8731 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8732         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8733         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8734         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8735         LDKUpdateFailMalformedHTLC msg_var = *msg;
8736         uint32_t msg_ref = 0;
8737         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
8738         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8739         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8740         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8741         msg_ref = (uintptr_t)msg_var.inner;
8742         if (msg_var.is_owned) {
8743                 msg_ref |= 1;
8744         }
8745         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8746 }
8747 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8748         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8749         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8750         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8751         LDKCommitmentSigned msg_var = *msg;
8752         uint32_t msg_ref = 0;
8753         msg_var = CommitmentSigned_clone(&msg_var);
8754         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8755         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8757         msg_ref = (uintptr_t)msg_var.inner;
8758         if (msg_var.is_owned) {
8759                 msg_ref |= 1;
8760         }
8761         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8762 }
8763 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8764         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8765         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8766         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8767         LDKRevokeAndACK msg_var = *msg;
8768         uint32_t msg_ref = 0;
8769         msg_var = RevokeAndACK_clone(&msg_var);
8770         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8771         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8772         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8773         msg_ref = (uintptr_t)msg_var.inner;
8774         if (msg_var.is_owned) {
8775                 msg_ref |= 1;
8776         }
8777         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8778 }
8779 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8780         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8781         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8782         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8783         LDKUpdateFee msg_var = *msg;
8784         uint32_t msg_ref = 0;
8785         msg_var = UpdateFee_clone(&msg_var);
8786         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8787         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8788         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8789         msg_ref = (uintptr_t)msg_var.inner;
8790         if (msg_var.is_owned) {
8791                 msg_ref |= 1;
8792         }
8793         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8794 }
8795 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8796         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8797         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8798         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8799         LDKAnnouncementSignatures msg_var = *msg;
8800         uint32_t msg_ref = 0;
8801         msg_var = AnnouncementSignatures_clone(&msg_var);
8802         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8803         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8804         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8805         msg_ref = (uintptr_t)msg_var.inner;
8806         if (msg_var.is_owned) {
8807                 msg_ref |= 1;
8808         }
8809         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8810 }
8811 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8813         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8814         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8815         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
8816 }
8817 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8818         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8819         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8820         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8821         LDKInit msg_var = *msg;
8822         uint32_t msg_ref = 0;
8823         msg_var = Init_clone(&msg_var);
8824         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8825         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8827         msg_ref = (uintptr_t)msg_var.inner;
8828         if (msg_var.is_owned) {
8829                 msg_ref |= 1;
8830         }
8831         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8832 }
8833 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8834         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8835         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8836         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8837         LDKChannelReestablish msg_var = *msg;
8838         uint32_t msg_ref = 0;
8839         msg_var = ChannelReestablish_clone(&msg_var);
8840         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8841         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8842         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8843         msg_ref = (uintptr_t)msg_var.inner;
8844         if (msg_var.is_owned) {
8845                 msg_ref |= 1;
8846         }
8847         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8848 }
8849 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8850         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8851         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8852         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8853         LDKChannelUpdate msg_var = *msg;
8854         uint32_t msg_ref = 0;
8855         msg_var = ChannelUpdate_clone(&msg_var);
8856         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8857         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8859         msg_ref = (uintptr_t)msg_var.inner;
8860         if (msg_var.is_owned) {
8861                 msg_ref |= 1;
8862         }
8863         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8864 }
8865 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8866         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8867         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8868         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8869         LDKErrorMessage msg_var = *msg;
8870         uint32_t msg_ref = 0;
8871         msg_var = ErrorMessage_clone(&msg_var);
8872         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8873         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8874         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8875         msg_ref = (uintptr_t)msg_var.inner;
8876         if (msg_var.is_owned) {
8877                 msg_ref |= 1;
8878         }
8879         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8880 }
8881 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8882         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8883         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8884         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8885 }
8886 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8887         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8888         atomic_init(&calls->refcnt, 1);
8889         calls->instance_ptr = o;
8890
8891         LDKChannelMessageHandler ret = {
8892                 .this_arg = (void*) calls,
8893                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8894                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8895                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8896                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8897                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8898                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8899                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8900                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8901                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8902                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8903                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8904                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8905                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8906                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8907                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8908                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8909                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8910                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8911                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8912                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8913                 .free = LDKChannelMessageHandler_JCalls_free,
8914                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8915         };
8916         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8917         return ret;
8918 }
8919 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8920         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8921         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8922         return (long)res_ptr;
8923 }
8924 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) {
8925         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8927         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8928         LDKPublicKey their_node_id_ref;
8929         CHECK(their_node_id->arr_len == 33);
8930         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8931         LDKInitFeatures their_features_conv;
8932         their_features_conv.inner = (void*)(their_features & (~1));
8933         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8934         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8935         their_features_conv = InitFeatures_clone(&their_features_conv);
8936         LDKOpenChannel msg_conv;
8937         msg_conv.inner = (void*)(msg & (~1));
8938         msg_conv.is_owned = false;
8939         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8940         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8941 }
8942
8943 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) {
8944         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8945         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8946         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8947         LDKPublicKey their_node_id_ref;
8948         CHECK(their_node_id->arr_len == 33);
8949         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8950         LDKInitFeatures their_features_conv;
8951         their_features_conv.inner = (void*)(their_features & (~1));
8952         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8953         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8954         their_features_conv = InitFeatures_clone(&their_features_conv);
8955         LDKAcceptChannel msg_conv;
8956         msg_conv.inner = (void*)(msg & (~1));
8957         msg_conv.is_owned = false;
8958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8959         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8960 }
8961
8962 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) {
8963         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8964         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8965         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8966         LDKPublicKey their_node_id_ref;
8967         CHECK(their_node_id->arr_len == 33);
8968         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8969         LDKFundingCreated msg_conv;
8970         msg_conv.inner = (void*)(msg & (~1));
8971         msg_conv.is_owned = false;
8972         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8973         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8974 }
8975
8976 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) {
8977         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8978         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8980         LDKPublicKey their_node_id_ref;
8981         CHECK(their_node_id->arr_len == 33);
8982         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8983         LDKFundingSigned msg_conv;
8984         msg_conv.inner = (void*)(msg & (~1));
8985         msg_conv.is_owned = false;
8986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8987         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8988 }
8989
8990 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) {
8991         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8993         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8994         LDKPublicKey their_node_id_ref;
8995         CHECK(their_node_id->arr_len == 33);
8996         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8997         LDKFundingLocked msg_conv;
8998         msg_conv.inner = (void*)(msg & (~1));
8999         msg_conv.is_owned = false;
9000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9001         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9002 }
9003
9004 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) {
9005         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9007         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9008         LDKPublicKey their_node_id_ref;
9009         CHECK(their_node_id->arr_len == 33);
9010         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9011         LDKInitFeatures their_features_conv;
9012         their_features_conv.inner = (void*)(their_features & (~1));
9013         their_features_conv.is_owned = false;
9014         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9015         LDKShutdown msg_conv;
9016         msg_conv.inner = (void*)(msg & (~1));
9017         msg_conv.is_owned = false;
9018         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9019         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9020 }
9021
9022 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) {
9023         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9024         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9025         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9026         LDKPublicKey their_node_id_ref;
9027         CHECK(their_node_id->arr_len == 33);
9028         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9029         LDKClosingSigned msg_conv;
9030         msg_conv.inner = (void*)(msg & (~1));
9031         msg_conv.is_owned = false;
9032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9033         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9034 }
9035
9036 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) {
9037         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9039         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9040         LDKPublicKey their_node_id_ref;
9041         CHECK(their_node_id->arr_len == 33);
9042         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9043         LDKUpdateAddHTLC msg_conv;
9044         msg_conv.inner = (void*)(msg & (~1));
9045         msg_conv.is_owned = false;
9046         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9047         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9048 }
9049
9050 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) {
9051         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9052         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9053         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9054         LDKPublicKey their_node_id_ref;
9055         CHECK(their_node_id->arr_len == 33);
9056         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9057         LDKUpdateFulfillHTLC msg_conv;
9058         msg_conv.inner = (void*)(msg & (~1));
9059         msg_conv.is_owned = false;
9060         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9061         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9062 }
9063
9064 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) {
9065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9067         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9068         LDKPublicKey their_node_id_ref;
9069         CHECK(their_node_id->arr_len == 33);
9070         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9071         LDKUpdateFailHTLC msg_conv;
9072         msg_conv.inner = (void*)(msg & (~1));
9073         msg_conv.is_owned = false;
9074         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9075         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9076 }
9077
9078 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) {
9079         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9080         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9081         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9082         LDKPublicKey their_node_id_ref;
9083         CHECK(their_node_id->arr_len == 33);
9084         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9085         LDKUpdateFailMalformedHTLC msg_conv;
9086         msg_conv.inner = (void*)(msg & (~1));
9087         msg_conv.is_owned = false;
9088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9089         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9090 }
9091
9092 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) {
9093         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9094         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9095         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9096         LDKPublicKey their_node_id_ref;
9097         CHECK(their_node_id->arr_len == 33);
9098         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9099         LDKCommitmentSigned msg_conv;
9100         msg_conv.inner = (void*)(msg & (~1));
9101         msg_conv.is_owned = false;
9102         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9103         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9104 }
9105
9106 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) {
9107         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9108         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9109         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9110         LDKPublicKey their_node_id_ref;
9111         CHECK(their_node_id->arr_len == 33);
9112         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9113         LDKRevokeAndACK msg_conv;
9114         msg_conv.inner = (void*)(msg & (~1));
9115         msg_conv.is_owned = false;
9116         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9117         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9118 }
9119
9120 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) {
9121         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9122         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9123         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9124         LDKPublicKey their_node_id_ref;
9125         CHECK(their_node_id->arr_len == 33);
9126         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9127         LDKUpdateFee msg_conv;
9128         msg_conv.inner = (void*)(msg & (~1));
9129         msg_conv.is_owned = false;
9130         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9131         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9132 }
9133
9134 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) {
9135         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9136         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9137         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9138         LDKPublicKey their_node_id_ref;
9139         CHECK(their_node_id->arr_len == 33);
9140         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9141         LDKAnnouncementSignatures msg_conv;
9142         msg_conv.inner = (void*)(msg & (~1));
9143         msg_conv.is_owned = false;
9144         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9145         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9146 }
9147
9148 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) {
9149         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9150         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9151         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9152         LDKPublicKey their_node_id_ref;
9153         CHECK(their_node_id->arr_len == 33);
9154         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9155         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9156 }
9157
9158 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9159         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9161         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9162         LDKPublicKey their_node_id_ref;
9163         CHECK(their_node_id->arr_len == 33);
9164         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9165         LDKInit msg_conv;
9166         msg_conv.inner = (void*)(msg & (~1));
9167         msg_conv.is_owned = false;
9168         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9169         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9170 }
9171
9172 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) {
9173         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9174         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9175         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9176         LDKPublicKey their_node_id_ref;
9177         CHECK(their_node_id->arr_len == 33);
9178         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9179         LDKChannelReestablish msg_conv;
9180         msg_conv.inner = (void*)(msg & (~1));
9181         msg_conv.is_owned = false;
9182         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9183         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9184 }
9185
9186 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) {
9187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9189         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9190         LDKPublicKey their_node_id_ref;
9191         CHECK(their_node_id->arr_len == 33);
9192         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9193         LDKChannelUpdate msg_conv;
9194         msg_conv.inner = (void*)(msg & (~1));
9195         msg_conv.is_owned = false;
9196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9197         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9198 }
9199
9200 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9201         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9202         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9203         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9204         LDKPublicKey their_node_id_ref;
9205         CHECK(their_node_id->arr_len == 33);
9206         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9207         LDKErrorMessage msg_conv;
9208         msg_conv.inner = (void*)(msg & (~1));
9209         msg_conv.is_owned = false;
9210         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9211         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9212 }
9213
9214 typedef struct LDKRoutingMessageHandler_JCalls {
9215         atomic_size_t refcnt;
9216         uint32_t instance_ptr;
9217         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9218 } LDKRoutingMessageHandler_JCalls;
9219 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9220         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9221         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9222                 FREE(j_calls);
9223         }
9224 }
9225 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9226         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9227         LDKNodeAnnouncement msg_var = *msg;
9228         uint32_t msg_ref = 0;
9229         msg_var = NodeAnnouncement_clone(&msg_var);
9230         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9231         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9233         msg_ref = (uintptr_t)msg_var.inner;
9234         if (msg_var.is_owned) {
9235                 msg_ref |= 1;
9236         }
9237         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9238         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9239         CHECK_ACCESS(ret_ptr);
9240         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9241         FREE((void*)ret);
9242         return ret_conv;
9243 }
9244 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9245         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9246         LDKChannelAnnouncement msg_var = *msg;
9247         uint32_t msg_ref = 0;
9248         msg_var = ChannelAnnouncement_clone(&msg_var);
9249         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9250         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9251         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9252         msg_ref = (uintptr_t)msg_var.inner;
9253         if (msg_var.is_owned) {
9254                 msg_ref |= 1;
9255         }
9256         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9257         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9258         CHECK_ACCESS(ret_ptr);
9259         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9260         FREE((void*)ret);
9261         return ret_conv;
9262 }
9263 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9264         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9265         LDKChannelUpdate msg_var = *msg;
9266         uint32_t msg_ref = 0;
9267         msg_var = ChannelUpdate_clone(&msg_var);
9268         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9269         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9270         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9271         msg_ref = (uintptr_t)msg_var.inner;
9272         if (msg_var.is_owned) {
9273                 msg_ref |= 1;
9274         }
9275         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9276         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9277         CHECK_ACCESS(ret_ptr);
9278         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9279         FREE((void*)ret);
9280         return ret_conv;
9281 }
9282 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9283         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9284         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
9285         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9286         ret_constr.datalen = ret->arr_len;
9287         if (ret_constr.datalen > 0)
9288                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9289         else
9290                 ret_constr.data = NULL;
9291         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9292         for (size_t h = 0; h < ret_constr.datalen; h++) {
9293                 uint32_t ret_conv_59 = ret_vals[h];
9294                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9295                 CHECK_ACCESS(ret_conv_59_ptr);
9296                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9297                 FREE((void*)ret_conv_59);
9298                 ret_constr.data[h] = ret_conv_59_conv;
9299         }
9300         return ret_constr;
9301 }
9302 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9303         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9304         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9305         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9306         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
9307         LDKCVec_NodeAnnouncementZ ret_constr;
9308         ret_constr.datalen = ret->arr_len;
9309         if (ret_constr.datalen > 0)
9310                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9311         else
9312                 ret_constr.data = NULL;
9313         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9314         for (size_t s = 0; s < ret_constr.datalen; s++) {
9315                 uint32_t ret_conv_18 = ret_vals[s];
9316                 LDKNodeAnnouncement ret_conv_18_conv;
9317                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9318                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9319                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9320                 ret_constr.data[s] = ret_conv_18_conv;
9321         }
9322         return ret_constr;
9323 }
9324 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9325         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9326         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9327         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9328         LDKInit init_var = *init;
9329         uint32_t init_ref = 0;
9330         init_var = Init_clone(&init_var);
9331         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9332         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9333         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9334         init_ref = (uintptr_t)init_var.inner;
9335         if (init_var.is_owned) {
9336                 init_ref |= 1;
9337         }
9338         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9339 }
9340 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9341         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9342         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9343         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9344         LDKReplyChannelRange msg_var = msg;
9345         uint32_t msg_ref = 0;
9346         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9347         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9348         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9349         msg_ref = (uintptr_t)msg_var.inner;
9350         if (msg_var.is_owned) {
9351                 msg_ref |= 1;
9352         }
9353         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9354         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9355         CHECK_ACCESS(ret_ptr);
9356         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9357         FREE((void*)ret);
9358         return ret_conv;
9359 }
9360 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9361         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9362         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9363         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9364         LDKReplyShortChannelIdsEnd msg_var = msg;
9365         uint32_t msg_ref = 0;
9366         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9367         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9369         msg_ref = (uintptr_t)msg_var.inner;
9370         if (msg_var.is_owned) {
9371                 msg_ref |= 1;
9372         }
9373         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9374         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9375         CHECK_ACCESS(ret_ptr);
9376         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9377         FREE((void*)ret);
9378         return ret_conv;
9379 }
9380 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9381         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9382         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9383         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9384         LDKQueryChannelRange msg_var = msg;
9385         uint32_t msg_ref = 0;
9386         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9387         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9388         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9389         msg_ref = (uintptr_t)msg_var.inner;
9390         if (msg_var.is_owned) {
9391                 msg_ref |= 1;
9392         }
9393         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9394         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9395         CHECK_ACCESS(ret_ptr);
9396         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9397         FREE((void*)ret);
9398         return ret_conv;
9399 }
9400 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9401         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9402         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9403         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9404         LDKQueryShortChannelIds msg_var = msg;
9405         uint32_t msg_ref = 0;
9406         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9407         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9408         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9409         msg_ref = (uintptr_t)msg_var.inner;
9410         if (msg_var.is_owned) {
9411                 msg_ref |= 1;
9412         }
9413         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9414         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9415         CHECK_ACCESS(ret_ptr);
9416         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9417         FREE((void*)ret);
9418         return ret_conv;
9419 }
9420 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9421         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9422         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9423         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9424 }
9425 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9426         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9427         atomic_init(&calls->refcnt, 1);
9428         calls->instance_ptr = o;
9429
9430         LDKRoutingMessageHandler ret = {
9431                 .this_arg = (void*) calls,
9432                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9433                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9434                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9435                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9436                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9437                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9438                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9439                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9440                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9441                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9442                 .free = LDKRoutingMessageHandler_JCalls_free,
9443                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9444         };
9445         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9446         return ret;
9447 }
9448 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9449         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9450         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9451         return (long)res_ptr;
9452 }
9453 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9454         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9455         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9456         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9457         LDKNodeAnnouncement msg_conv;
9458         msg_conv.inner = (void*)(msg & (~1));
9459         msg_conv.is_owned = false;
9460         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9461         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9462         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9463         return (uint32_t)ret_conv;
9464 }
9465
9466 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9467         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9468         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9469         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9470         LDKChannelAnnouncement msg_conv;
9471         msg_conv.inner = (void*)(msg & (~1));
9472         msg_conv.is_owned = false;
9473         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9474         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9475         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9476         return (uint32_t)ret_conv;
9477 }
9478
9479 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9480         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9481         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9482         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9483         LDKChannelUpdate msg_conv;
9484         msg_conv.inner = (void*)(msg & (~1));
9485         msg_conv.is_owned = false;
9486         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9487         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9488         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9489         return (uint32_t)ret_conv;
9490 }
9491
9492 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) {
9493         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9494         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9495         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9496         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9497         uint32_tArray ret_arr = NULL;
9498         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9499         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9500         for (size_t h = 0; h < ret_var.datalen; h++) {
9501                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9502                 *ret_conv_59_conv = ret_var.data[h];
9503                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9504         }
9505         
9506         FREE(ret_var.data);
9507         return ret_arr;
9508 }
9509
9510 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) {
9511         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9512         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9513         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9514         LDKPublicKey starting_point_ref;
9515         CHECK(starting_point->arr_len == 33);
9516         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9517         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9518         uint32_tArray ret_arr = NULL;
9519         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9520         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9521         for (size_t s = 0; s < ret_var.datalen; s++) {
9522                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9523                 uint32_t ret_conv_18_ref = 0;
9524                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9525                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9526                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9527                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9528                 if (ret_conv_18_var.is_owned) {
9529                         ret_conv_18_ref |= 1;
9530                 }
9531                 ret_arr_ptr[s] = ret_conv_18_ref;
9532         }
9533         
9534         FREE(ret_var.data);
9535         return ret_arr;
9536 }
9537
9538 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
9539         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9541         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9542         LDKPublicKey their_node_id_ref;
9543         CHECK(their_node_id->arr_len == 33);
9544         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9545         LDKInit init_conv;
9546         init_conv.inner = (void*)(init & (~1));
9547         init_conv.is_owned = false;
9548         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9549         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9550 }
9551
9552 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) {
9553         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9554         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9555         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9556         LDKPublicKey their_node_id_ref;
9557         CHECK(their_node_id->arr_len == 33);
9558         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9559         LDKReplyChannelRange msg_conv;
9560         msg_conv.inner = (void*)(msg & (~1));
9561         msg_conv.is_owned = (msg & 1) || (msg == 0);
9562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9563         msg_conv = ReplyChannelRange_clone(&msg_conv);
9564         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9565         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9566         return (uint32_t)ret_conv;
9567 }
9568
9569 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) {
9570         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9571         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9572         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9573         LDKPublicKey their_node_id_ref;
9574         CHECK(their_node_id->arr_len == 33);
9575         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9576         LDKReplyShortChannelIdsEnd msg_conv;
9577         msg_conv.inner = (void*)(msg & (~1));
9578         msg_conv.is_owned = (msg & 1) || (msg == 0);
9579         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9580         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9581         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9582         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9583         return (uint32_t)ret_conv;
9584 }
9585
9586 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) {
9587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9589         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9590         LDKPublicKey their_node_id_ref;
9591         CHECK(their_node_id->arr_len == 33);
9592         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9593         LDKQueryChannelRange msg_conv;
9594         msg_conv.inner = (void*)(msg & (~1));
9595         msg_conv.is_owned = (msg & 1) || (msg == 0);
9596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9597         msg_conv = QueryChannelRange_clone(&msg_conv);
9598         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9599         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9600         return (uint32_t)ret_conv;
9601 }
9602
9603 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) {
9604         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9605         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9606         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9607         LDKPublicKey their_node_id_ref;
9608         CHECK(their_node_id->arr_len == 33);
9609         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9610         LDKQueryShortChannelIds msg_conv;
9611         msg_conv.inner = (void*)(msg & (~1));
9612         msg_conv.is_owned = (msg & 1) || (msg == 0);
9613         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9614         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9615         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9616         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9617         return (uint32_t)ret_conv;
9618 }
9619
9620 typedef struct LDKCustomMessageReader_JCalls {
9621         atomic_size_t refcnt;
9622         uint32_t instance_ptr;
9623 } LDKCustomMessageReader_JCalls;
9624 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9625         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9626         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9627                 FREE(j_calls);
9628         }
9629 }
9630 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9631         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9632         LDKu8slice buffer_var = buffer;
9633         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9634         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9635         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
9636         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9637         CHECK_ACCESS(ret_ptr);
9638         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9639         FREE((void*)ret);
9640         return ret_conv;
9641 }
9642 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9643         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9644         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9645 }
9646 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9647         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9648         atomic_init(&calls->refcnt, 1);
9649         calls->instance_ptr = o;
9650
9651         LDKCustomMessageReader ret = {
9652                 .this_arg = (void*) calls,
9653                 .read = read_LDKCustomMessageReader_jcall,
9654                 .free = LDKCustomMessageReader_JCalls_free,
9655         };
9656         return ret;
9657 }
9658 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9659         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9660         *res_ptr = LDKCustomMessageReader_init(o);
9661         return (long)res_ptr;
9662 }
9663 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9664         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9665         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9666         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9667         LDKu8slice buffer_ref;
9668         buffer_ref.datalen = buffer->arr_len;
9669         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9670         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9671         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9672         return (uint32_t)ret_conv;
9673 }
9674
9675 typedef struct LDKCustomMessageHandler_JCalls {
9676         atomic_size_t refcnt;
9677         uint32_t instance_ptr;
9678         LDKCustomMessageReader_JCalls* CustomMessageReader;
9679 } LDKCustomMessageHandler_JCalls;
9680 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9681         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9682         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9683                 FREE(j_calls);
9684         }
9685 }
9686 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9687         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9688         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9689         *msg_ret = msg;
9690         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9691         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9692         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9693         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9694         CHECK_ACCESS(ret_ptr);
9695         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9696         FREE((void*)ret);
9697         return ret_conv;
9698 }
9699 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9700         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9701         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9702         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9703         ret_constr.datalen = ret->arr_len;
9704         if (ret_constr.datalen > 0)
9705                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9706         else
9707                 ret_constr.data = NULL;
9708         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9709         for (size_t z = 0; z < ret_constr.datalen; z++) {
9710                 uint32_t ret_conv_25 = ret_vals[z];
9711                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9712                 CHECK_ACCESS(ret_conv_25_ptr);
9713                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9714                 FREE((void*)ret_conv_25);
9715                 ret_constr.data[z] = ret_conv_25_conv;
9716         }
9717         return ret_constr;
9718 }
9719 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9720         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9721         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9722         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9723 }
9724 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9725         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9726         atomic_init(&calls->refcnt, 1);
9727         calls->instance_ptr = o;
9728
9729         LDKCustomMessageHandler ret = {
9730                 .this_arg = (void*) calls,
9731                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9732                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9733                 .free = LDKCustomMessageHandler_JCalls_free,
9734                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9735         };
9736         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9737         return ret;
9738 }
9739 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9740         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9741         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9742         return (long)res_ptr;
9743 }
9744 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) {
9745         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9746         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9747         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9748         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9749         CHECK_ACCESS(msg_ptr);
9750         LDKType msg_conv = *(LDKType*)(msg_ptr);
9751         if (msg_conv.free == LDKType_JCalls_free) {
9752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9753                 LDKType_JCalls_cloned(&msg_conv);
9754         }
9755         LDKPublicKey sender_node_id_ref;
9756         CHECK(sender_node_id->arr_len == 33);
9757         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9758         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9759         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9760         return (uint32_t)ret_conv;
9761 }
9762
9763 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9764         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9765         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9766         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9767         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9768         uint32_tArray ret_arr = NULL;
9769         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9770         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9771         for (size_t z = 0; z < ret_var.datalen; z++) {
9772                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9773                 *ret_conv_25_conv = ret_var.data[z];
9774                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9775         }
9776         
9777         FREE(ret_var.data);
9778         return ret_arr;
9779 }
9780
9781 typedef struct LDKSocketDescriptor_JCalls {
9782         atomic_size_t refcnt;
9783         uint32_t instance_ptr;
9784 } LDKSocketDescriptor_JCalls;
9785 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9786         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9787         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9788                 FREE(j_calls);
9789         }
9790 }
9791 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9792         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9793         LDKu8slice data_var = data;
9794         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9795         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9796         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
9797 }
9798 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9799         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9800         js_invoke_function_0(j_calls->instance_ptr, 79);
9801 }
9802 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9803         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9804         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9805         *other_arg_clone = SocketDescriptor_clone(other_arg);
9806         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9807 }
9808 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9809         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9810         return js_invoke_function_0(j_calls->instance_ptr, 81);
9811 }
9812 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9813         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9814         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9815 }
9816 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9817         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9818         atomic_init(&calls->refcnt, 1);
9819         calls->instance_ptr = o;
9820
9821         LDKSocketDescriptor ret = {
9822                 .this_arg = (void*) calls,
9823                 .send_data = send_data_LDKSocketDescriptor_jcall,
9824                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9825                 .eq = eq_LDKSocketDescriptor_jcall,
9826                 .hash = hash_LDKSocketDescriptor_jcall,
9827                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9828                 .free = LDKSocketDescriptor_JCalls_free,
9829         };
9830         return ret;
9831 }
9832 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9833         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9834         *res_ptr = LDKSocketDescriptor_init(o);
9835         return (long)res_ptr;
9836 }
9837 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9838         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9839         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9840         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9841         LDKu8slice data_ref;
9842         data_ref.datalen = data->arr_len;
9843         data_ref.data = data->elems /* XXX data leaks */;
9844         uint32_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9845         return ret_val;
9846 }
9847
9848 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9849         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9850         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9851         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9852         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9853 }
9854
9855 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9858         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9859         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9860         return ret_val;
9861 }
9862
9863 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9864         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9865         switch(obj->tag) {
9866                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9867                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9868                 case LDKEffectiveCapacity_Total: return 2;
9869                 case LDKEffectiveCapacity_Infinite: return 3;
9870                 case LDKEffectiveCapacity_Unknown: return 4;
9871                 default: abort();
9872         }
9873 }
9874 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9875         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9876         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9877         return obj->exact_liquidity.liquidity_msat;
9878 }
9879 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9880         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9881         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9882         return obj->maximum_htlc.amount_msat;
9883 }
9884 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9885         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9886         assert(obj->tag == LDKEffectiveCapacity_Total);
9887         return obj->total.capacity_msat;
9888 }
9889 typedef struct LDKScore_JCalls {
9890         atomic_size_t refcnt;
9891         uint32_t instance_ptr;
9892 } LDKScore_JCalls;
9893 static void LDKScore_JCalls_free(void* this_arg) {
9894         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9895         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9896                 FREE(j_calls);
9897         }
9898 }
9899 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
9900         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9901         LDKNodeId source_var = *source;
9902         uint32_t source_ref = 0;
9903         source_var = NodeId_clone(&source_var);
9904         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9905         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9906         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9907         source_ref = (uintptr_t)source_var.inner;
9908         if (source_var.is_owned) {
9909                 source_ref |= 1;
9910         }
9911         LDKNodeId target_var = *target;
9912         uint32_t target_ref = 0;
9913         target_var = NodeId_clone(&target_var);
9914         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9915         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9916         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9917         target_ref = (uintptr_t)target_var.inner;
9918         if (target_var.is_owned) {
9919                 target_ref |= 1;
9920         }
9921         return js_invoke_function_5(j_calls->instance_ptr, 82, (uint32_t)short_channel_id, (uint32_t)send_amt_msat, (uint32_t)capacity_msat, (uint32_t)source_ref, (uint32_t)target_ref);
9922 }
9923 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9924         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9925         LDKCVec_RouteHopZ path_var = path;
9926         uint32_tArray path_arr = NULL;
9927         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9928         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9929         for (size_t k = 0; k < path_var.datalen; k++) {
9930                 LDKRouteHop path_conv_10_var = path_var.data[k];
9931                 uint32_t path_conv_10_ref = 0;
9932                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9933                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9934                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9935                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9936                 if (path_conv_10_var.is_owned) {
9937                         path_conv_10_ref |= 1;
9938                 }
9939                 path_arr_ptr[k] = path_conv_10_ref;
9940         }
9941         
9942         FREE(path_var.data);
9943         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
9944 }
9945 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9946         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9947         LDKCVec_RouteHopZ path_var = path;
9948         uint32_tArray path_arr = NULL;
9949         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9950         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9951         for (size_t k = 0; k < path_var.datalen; k++) {
9952                 LDKRouteHop path_conv_10_var = path_var.data[k];
9953                 uint32_t path_conv_10_ref = 0;
9954                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9955                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9957                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9958                 if (path_conv_10_var.is_owned) {
9959                         path_conv_10_ref |= 1;
9960                 }
9961                 path_arr_ptr[k] = path_conv_10_ref;
9962         }
9963         
9964         FREE(path_var.data);
9965         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
9966 }
9967 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9968         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9969         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
9970         LDKCVec_u8Z ret_ref;
9971         ret_ref.datalen = ret->arr_len;
9972         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9973         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
9974         return ret_ref;
9975 }
9976 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9977         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9978         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9979 }
9980 static inline LDKScore LDKScore_init (JSValue o) {
9981         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9982         atomic_init(&calls->refcnt, 1);
9983         calls->instance_ptr = o;
9984
9985         LDKScore ret = {
9986                 .this_arg = (void*) calls,
9987                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9988                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9989                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9990                 .write = write_LDKScore_jcall,
9991                 .free = LDKScore_JCalls_free,
9992         };
9993         return ret;
9994 }
9995 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
9996         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9997         *res_ptr = LDKScore_init(o);
9998         return (long)res_ptr;
9999 }
10000 int64_t  __attribute__((export_name("TS_Score_channel_penalty_msat"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, uint32_t source, uint32_t target) {
10001         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10002         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10003         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10004         LDKNodeId source_conv;
10005         source_conv.inner = (void*)(source & (~1));
10006         source_conv.is_owned = false;
10007         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10008         LDKNodeId target_conv;
10009         target_conv.inner = (void*)(target & (~1));
10010         target_conv.is_owned = false;
10011         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10012         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
10013         return ret_val;
10014 }
10015
10016 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) {
10017         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10018         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10019         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10020         LDKCVec_RouteHopZ path_constr;
10021         path_constr.datalen = path->arr_len;
10022         if (path_constr.datalen > 0)
10023                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10024         else
10025                 path_constr.data = NULL;
10026         uint32_t* path_vals = path->elems /* XXX path leaks */;
10027         for (size_t k = 0; k < path_constr.datalen; k++) {
10028                 uint32_t path_conv_10 = path_vals[k];
10029                 LDKRouteHop path_conv_10_conv;
10030                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10031                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10032                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10033                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10034                 path_constr.data[k] = path_conv_10_conv;
10035         }
10036         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10037 }
10038
10039 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
10040         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10042         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10043         LDKCVec_RouteHopZ path_constr;
10044         path_constr.datalen = path->arr_len;
10045         if (path_constr.datalen > 0)
10046                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10047         else
10048                 path_constr.data = NULL;
10049         uint32_t* path_vals = path->elems /* XXX path leaks */;
10050         for (size_t k = 0; k < path_constr.datalen; k++) {
10051                 uint32_t path_conv_10 = path_vals[k];
10052                 LDKRouteHop path_conv_10_conv;
10053                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10054                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10055                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10056                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10057                 path_constr.data[k] = path_conv_10_conv;
10058         }
10059         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10060 }
10061
10062 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
10063         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10065         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10066         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10067         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
10068         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
10069         CVec_u8Z_free(ret_var);
10070         return ret_arr;
10071 }
10072
10073 typedef struct LDKLockableScore_JCalls {
10074         atomic_size_t refcnt;
10075         uint32_t instance_ptr;
10076 } LDKLockableScore_JCalls;
10077 static void LDKLockableScore_JCalls_free(void* this_arg) {
10078         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10079         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10080                 FREE(j_calls);
10081         }
10082 }
10083 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10084         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10085         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
10086         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10087         CHECK_ACCESS(ret_ptr);
10088         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10089         if (ret_conv.free == LDKScore_JCalls_free) {
10090                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10091                 LDKScore_JCalls_cloned(&ret_conv);
10092         }// WARNING: we may need a move here but no clone is available for LDKScore
10093         
10094         return ret_conv;
10095 }
10096 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10097         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10098         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10099 }
10100 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10101         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10102         atomic_init(&calls->refcnt, 1);
10103         calls->instance_ptr = o;
10104
10105         LDKLockableScore ret = {
10106                 .this_arg = (void*) calls,
10107                 .lock = lock_LDKLockableScore_jcall,
10108                 .free = LDKLockableScore_JCalls_free,
10109         };
10110         return ret;
10111 }
10112 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10113         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10114         *res_ptr = LDKLockableScore_init(o);
10115         return (long)res_ptr;
10116 }
10117 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10120         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10121         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10122         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10123         return (uint32_t)ret_ret;
10124 }
10125
10126 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10127         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10128         switch(obj->tag) {
10129                 case LDKFallback_SegWitProgram: return 0;
10130                 case LDKFallback_PubKeyHash: return 1;
10131                 case LDKFallback_ScriptHash: return 2;
10132                 default: abort();
10133         }
10134 }
10135 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10136         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10137         assert(obj->tag == LDKFallback_SegWitProgram);
10138                         uint8_t version_val = obj->seg_wit_program.version._0;
10139         return version_val;
10140 }
10141 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10142         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10143         assert(obj->tag == LDKFallback_SegWitProgram);
10144                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10145                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10146                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10147         return program_arr;
10148 }
10149 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10150         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10151         assert(obj->tag == LDKFallback_PubKeyHash);
10152                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10153                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10154         return pub_key_hash_arr;
10155 }
10156 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10157         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10158         assert(obj->tag == LDKFallback_ScriptHash);
10159                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10160                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10161         return script_hash_arr;
10162 }
10163 typedef struct LDKPayer_JCalls {
10164         atomic_size_t refcnt;
10165         uint32_t instance_ptr;
10166 } LDKPayer_JCalls;
10167 static void LDKPayer_JCalls_free(void* this_arg) {
10168         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10169         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10170                 FREE(j_calls);
10171         }
10172 }
10173 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10174         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10175         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10176         LDKPublicKey ret_ref;
10177         CHECK(ret->arr_len == 33);
10178         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10179         return ret_ref;
10180 }
10181 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10182         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10183         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10184         LDKCVec_ChannelDetailsZ ret_constr;
10185         ret_constr.datalen = ret->arr_len;
10186         if (ret_constr.datalen > 0)
10187                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10188         else
10189                 ret_constr.data = NULL;
10190         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10191         for (size_t q = 0; q < ret_constr.datalen; q++) {
10192                 uint32_t ret_conv_16 = ret_vals[q];
10193                 LDKChannelDetails ret_conv_16_conv;
10194                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10195                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10196                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10197                 ret_constr.data[q] = ret_conv_16_conv;
10198         }
10199         return ret_constr;
10200 }
10201 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10202         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10203         LDKRoute route_var = *route;
10204         uint32_t route_ref = 0;
10205         route_var = Route_clone(&route_var);
10206         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10207         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10208         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10209         route_ref = (uintptr_t)route_var.inner;
10210         if (route_var.is_owned) {
10211                 route_ref |= 1;
10212         }
10213         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10214         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10215         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10216         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10217         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 89, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr);
10218         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10219         CHECK_ACCESS(ret_ptr);
10220         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10221         FREE((void*)ret);
10222         return ret_conv;
10223 }
10224 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10225         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10226         LDKRoute route_var = *route;
10227         uint32_t route_ref = 0;
10228         route_var = Route_clone(&route_var);
10229         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10230         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10231         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10232         route_ref = (uintptr_t)route_var.inner;
10233         if (route_var.is_owned) {
10234                 route_ref |= 1;
10235         }
10236         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10237         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10238         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10239         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10240         CHECK_ACCESS(ret_ptr);
10241         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10242         FREE((void*)ret);
10243         return ret_conv;
10244 }
10245 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10246         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10247         LDKRoute route_var = *route;
10248         uint32_t route_ref = 0;
10249         route_var = Route_clone(&route_var);
10250         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10251         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10252         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10253         route_ref = (uintptr_t)route_var.inner;
10254         if (route_var.is_owned) {
10255                 route_ref |= 1;
10256         }
10257         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10258         memcpy(payment_id_arr->elems, payment_id.data, 32);
10259         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10260         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10261         CHECK_ACCESS(ret_ptr);
10262         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10263         FREE((void*)ret);
10264         return ret_conv;
10265 }
10266 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10267         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10268         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10269         memcpy(payment_id_arr->elems, payment_id.data, 32);
10270         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10271 }
10272 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10273         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10274         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10275 }
10276 static inline LDKPayer LDKPayer_init (JSValue o) {
10277         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10278         atomic_init(&calls->refcnt, 1);
10279         calls->instance_ptr = o;
10280
10281         LDKPayer ret = {
10282                 .this_arg = (void*) calls,
10283                 .node_id = node_id_LDKPayer_jcall,
10284                 .first_hops = first_hops_LDKPayer_jcall,
10285                 .send_payment = send_payment_LDKPayer_jcall,
10286                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10287                 .retry_payment = retry_payment_LDKPayer_jcall,
10288                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10289                 .free = LDKPayer_JCalls_free,
10290         };
10291         return ret;
10292 }
10293 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10294         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10295         *res_ptr = LDKPayer_init(o);
10296         return (long)res_ptr;
10297 }
10298 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10301         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10302         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10303         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10304         return ret_arr;
10305 }
10306
10307 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10308         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10309         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10310         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10311         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10312         uint32_tArray ret_arr = NULL;
10313         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10314         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10315         for (size_t q = 0; q < ret_var.datalen; q++) {
10316                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10317                 uint32_t ret_conv_16_ref = 0;
10318                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10319                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10320                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10321                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10322                 if (ret_conv_16_var.is_owned) {
10323                         ret_conv_16_ref |= 1;
10324                 }
10325                 ret_arr_ptr[q] = ret_conv_16_ref;
10326         }
10327         
10328         FREE(ret_var.data);
10329         return ret_arr;
10330 }
10331
10332 uint32_t  __attribute__((export_name("TS_Payer_send_payment"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
10333         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10335         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10336         LDKRoute route_conv;
10337         route_conv.inner = (void*)(route & (~1));
10338         route_conv.is_owned = false;
10339         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10340         LDKThirtyTwoBytes payment_hash_ref;
10341         CHECK(payment_hash->arr_len == 32);
10342         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10343         LDKThirtyTwoBytes payment_secret_ref;
10344         CHECK(payment_secret->arr_len == 32);
10345         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10346         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10347         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10348         return (uint32_t)ret_conv;
10349 }
10350
10351 uint32_t  __attribute__((export_name("TS_Payer_send_spontaneous_payment"))) TS_Payer_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
10352         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10353         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10354         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10355         LDKRoute route_conv;
10356         route_conv.inner = (void*)(route & (~1));
10357         route_conv.is_owned = false;
10358         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10359         LDKThirtyTwoBytes payment_preimage_ref;
10360         CHECK(payment_preimage->arr_len == 32);
10361         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10362         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10363         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10364         return (uint32_t)ret_conv;
10365 }
10366
10367 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10368         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10370         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10371         LDKRoute route_conv;
10372         route_conv.inner = (void*)(route & (~1));
10373         route_conv.is_owned = false;
10374         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10375         LDKThirtyTwoBytes payment_id_ref;
10376         CHECK(payment_id->arr_len == 32);
10377         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10378         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10379         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10380         return (uint32_t)ret_conv;
10381 }
10382
10383 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10386         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10387         LDKThirtyTwoBytes payment_id_ref;
10388         CHECK(payment_id->arr_len == 32);
10389         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10390         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10391 }
10392
10393 typedef struct LDKRouter_JCalls {
10394         atomic_size_t refcnt;
10395         uint32_t instance_ptr;
10396 } LDKRouter_JCalls;
10397 static void LDKRouter_JCalls_free(void* this_arg) {
10398         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10399         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10400                 FREE(j_calls);
10401         }
10402 }
10403 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
10404         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10405         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10406         memcpy(payer_arr->elems, payer.compressed_form, 33);
10407         LDKRouteParameters route_params_var = *route_params;
10408         uint32_t route_params_ref = 0;
10409         route_params_var = RouteParameters_clone(&route_params_var);
10410         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10411         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10412         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10413         route_params_ref = (uintptr_t)route_params_var.inner;
10414         if (route_params_var.is_owned) {
10415                 route_params_ref |= 1;
10416         }
10417         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10418         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10419         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10420         uint32_tArray first_hops_arr = NULL;
10421         if (first_hops != NULL) {
10422                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10423                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10424                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10425                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10426                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10427                         uint32_t first_hops_conv_16_ref = 0;
10428                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10429                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10430                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10431                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10432                         if (first_hops_conv_16_var.is_owned) {
10433                                 first_hops_conv_16_ref |= 1;
10434                         }
10435                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10436                 }
10437         
10438         }
10439         // WARNING: This object doesn't live past this scope, needs clone!
10440         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10441         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 93, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer);
10442         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10443         CHECK_ACCESS(ret_ptr);
10444         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10445         FREE((void*)ret);
10446         return ret_conv;
10447 }
10448 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10449         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10450         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10451 }
10452 static inline LDKRouter LDKRouter_init (JSValue o) {
10453         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10454         atomic_init(&calls->refcnt, 1);
10455         calls->instance_ptr = o;
10456
10457         LDKRouter ret = {
10458                 .this_arg = (void*) calls,
10459                 .find_route = find_route_LDKRouter_jcall,
10460                 .free = LDKRouter_JCalls_free,
10461         };
10462         return ret;
10463 }
10464 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10465         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10466         *res_ptr = LDKRouter_init(o);
10467         return (long)res_ptr;
10468 }
10469 uint32_t  __attribute__((export_name("TS_Router_find_route"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t route_params, int8_tArray payment_hash, uint32_tArray first_hops, uint32_t scorer) {
10470         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10471         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10472         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10473         LDKPublicKey payer_ref;
10474         CHECK(payer->arr_len == 33);
10475         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10476         LDKRouteParameters route_params_conv;
10477         route_params_conv.inner = (void*)(route_params & (~1));
10478         route_params_conv.is_owned = false;
10479         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10480         unsigned char payment_hash_arr[32];
10481         CHECK(payment_hash->arr_len == 32);
10482         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10483         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10484         LDKCVec_ChannelDetailsZ first_hops_constr;
10485         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10486         if (first_hops != 0) {
10487                 first_hops_constr.datalen = first_hops->arr_len;
10488                 if (first_hops_constr.datalen > 0)
10489                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10490                 else
10491                         first_hops_constr.data = NULL;
10492                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10493                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10494                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10495                         LDKChannelDetails first_hops_conv_16_conv;
10496                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10497                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10498                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10499                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10500                 }
10501                 first_hops_ptr = &first_hops_constr;
10502         }
10503         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10504         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10505         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10506         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10507         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
10508         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10509         return (uint32_t)ret_conv;
10510 }
10511
10512 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10513         LDKStr ret_str = _ldk_get_compiled_version();
10514         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10515         Str_free(ret_str);
10516         return ret_conv;
10517 }
10518
10519 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10520         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10521         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10522         Str_free(ret_str);
10523         return ret_conv;
10524 }
10525
10526 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
10527         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10528         *ret_copy = Bech32Error_clone(arg);
10529 uint32_t ret_ref = (uintptr_t)ret_copy;
10530         return ret_ref;
10531 }
10532 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
10533         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
10534         uint32_t ret_val = Bech32Error_clone_ptr(arg_conv);
10535         return ret_val;
10536 }
10537
10538 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
10539         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
10540         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10541         *ret_copy = Bech32Error_clone(orig_conv);
10542         uint32_t ret_ref = (uintptr_t)ret_copy;
10543         return ret_ref;
10544 }
10545
10546 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
10547         if ((o & 1) != 0) return;
10548         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10549         CHECK_ACCESS(o_ptr);
10550         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
10551         FREE((void*)o);
10552         Bech32Error_free(o_conv);
10553 }
10554
10555 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10556         LDKTransaction _res_ref;
10557         _res_ref.datalen = _res->arr_len;
10558         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10559         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10560         _res_ref.data_is_owned = true;
10561         Transaction_free(_res_ref);
10562 }
10563
10564 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10565         LDKCVec_u8Z script_pubkey_ref;
10566         script_pubkey_ref.datalen = script_pubkey->arr_len;
10567         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10568         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10569         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10570         *ret_ref = TxOut_new(script_pubkey_ref, value);
10571         return (uint32_t)ret_ref;
10572 }
10573
10574 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10575         if ((_res & 1) != 0) return;
10576         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10577         CHECK_ACCESS(_res_ptr);
10578         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10579         FREE((void*)_res);
10580         TxOut_free(_res_conv);
10581 }
10582
10583 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10584         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10585         *ret_ref = TxOut_clone(arg);
10586         return (uint32_t)ret_ref;
10587 }
10588 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10589         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10590         uint32_t ret_val = TxOut_clone_ptr(arg_conv);
10591         return ret_val;
10592 }
10593
10594 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10595         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10596         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10597         *ret_ref = TxOut_clone(orig_conv);
10598         return (uint32_t)ret_ref;
10599 }
10600
10601 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10602         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10603         Str_free(dummy);
10604 }
10605
10606 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10607         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10608         *ret_conv = CResult_NoneNoneZ_ok();
10609         return (uint32_t)ret_conv;
10610 }
10611
10612 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10613         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10614         *ret_conv = CResult_NoneNoneZ_err();
10615         return (uint32_t)ret_conv;
10616 }
10617
10618 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10619         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10620         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10621         return ret_val;
10622 }
10623
10624 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10625         if ((_res & 1) != 0) return;
10626         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10627         CHECK_ACCESS(_res_ptr);
10628         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10629         FREE((void*)_res);
10630         CResult_NoneNoneZ_free(_res_conv);
10631 }
10632
10633 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10634         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10635         *ret_conv = CResult_NoneNoneZ_clone(arg);
10636         return (uint32_t)ret_conv;
10637 }
10638 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10639         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10640         uint32_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10641         return ret_val;
10642 }
10643
10644 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10645         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10646         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10647         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10648         return (uint32_t)ret_conv;
10649 }
10650
10651 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10652         LDKCounterpartyCommitmentSecrets o_conv;
10653         o_conv.inner = (void*)(o & (~1));
10654         o_conv.is_owned = (o & 1) || (o == 0);
10655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10656         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10657         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10658         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10659         return (uint32_t)ret_conv;
10660 }
10661
10662 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10663         LDKDecodeError e_conv;
10664         e_conv.inner = (void*)(e & (~1));
10665         e_conv.is_owned = (e & 1) || (e == 0);
10666         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10667         e_conv = DecodeError_clone(&e_conv);
10668         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10669         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10670         return (uint32_t)ret_conv;
10671 }
10672
10673 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10674         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10675         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10676         return ret_val;
10677 }
10678
10679 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10680         if ((_res & 1) != 0) return;
10681         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10682         CHECK_ACCESS(_res_ptr);
10683         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10684         FREE((void*)_res);
10685         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10686 }
10687
10688 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10689         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10690         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10691         return (uint32_t)ret_conv;
10692 }
10693 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10694         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10695         uint32_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10696         return ret_val;
10697 }
10698
10699 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10700         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10701         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10702         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10703         return (uint32_t)ret_conv;
10704 }
10705
10706 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10707         LDKSecretKey o_ref;
10708         CHECK(o->arr_len == 32);
10709         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10710         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10711         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10712         return (uint32_t)ret_conv;
10713 }
10714
10715 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10716         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10717         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10718         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10719         return (uint32_t)ret_conv;
10720 }
10721
10722 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10723         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10724         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
10725         return ret_val;
10726 }
10727
10728 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10729         if ((_res & 1) != 0) return;
10730         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10731         CHECK_ACCESS(_res_ptr);
10732         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10733         FREE((void*)_res);
10734         CResult_SecretKeyErrorZ_free(_res_conv);
10735 }
10736
10737 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10738         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10739         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10740         return (uint32_t)ret_conv;
10741 }
10742 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10743         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10744         uint32_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10745         return ret_val;
10746 }
10747
10748 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10749         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10750         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10751         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10752         return (uint32_t)ret_conv;
10753 }
10754
10755 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10756         LDKPublicKey o_ref;
10757         CHECK(o->arr_len == 33);
10758         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10759         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10760         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10761         return (uint32_t)ret_conv;
10762 }
10763
10764 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10765         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10766         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10767         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10768         return (uint32_t)ret_conv;
10769 }
10770
10771 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10772         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10773         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
10774         return ret_val;
10775 }
10776
10777 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10778         if ((_res & 1) != 0) return;
10779         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10780         CHECK_ACCESS(_res_ptr);
10781         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10782         FREE((void*)_res);
10783         CResult_PublicKeyErrorZ_free(_res_conv);
10784 }
10785
10786 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10787         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10788         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10789         return (uint32_t)ret_conv;
10790 }
10791 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10792         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10793         uint32_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10794         return ret_val;
10795 }
10796
10797 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10798         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10799         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10800         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10801         return (uint32_t)ret_conv;
10802 }
10803
10804 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10805         LDKTxCreationKeys o_conv;
10806         o_conv.inner = (void*)(o & (~1));
10807         o_conv.is_owned = (o & 1) || (o == 0);
10808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10809         o_conv = TxCreationKeys_clone(&o_conv);
10810         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10811         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10812         return (uint32_t)ret_conv;
10813 }
10814
10815 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10816         LDKDecodeError e_conv;
10817         e_conv.inner = (void*)(e & (~1));
10818         e_conv.is_owned = (e & 1) || (e == 0);
10819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10820         e_conv = DecodeError_clone(&e_conv);
10821         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10822         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10823         return (uint32_t)ret_conv;
10824 }
10825
10826 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10827         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10828         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10829         return ret_val;
10830 }
10831
10832 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10833         if ((_res & 1) != 0) return;
10834         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10835         CHECK_ACCESS(_res_ptr);
10836         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10837         FREE((void*)_res);
10838         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10839 }
10840
10841 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10842         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10843         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10844         return (uint32_t)ret_conv;
10845 }
10846 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10847         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10848         uint32_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10849         return ret_val;
10850 }
10851
10852 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10853         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10854         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10855         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10856         return (uint32_t)ret_conv;
10857 }
10858
10859 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10860         LDKChannelPublicKeys o_conv;
10861         o_conv.inner = (void*)(o & (~1));
10862         o_conv.is_owned = (o & 1) || (o == 0);
10863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10864         o_conv = ChannelPublicKeys_clone(&o_conv);
10865         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10866         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10867         return (uint32_t)ret_conv;
10868 }
10869
10870 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10871         LDKDecodeError e_conv;
10872         e_conv.inner = (void*)(e & (~1));
10873         e_conv.is_owned = (e & 1) || (e == 0);
10874         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10875         e_conv = DecodeError_clone(&e_conv);
10876         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10877         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10878         return (uint32_t)ret_conv;
10879 }
10880
10881 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10882         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10883         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10884         return ret_val;
10885 }
10886
10887 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10888         if ((_res & 1) != 0) return;
10889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10890         CHECK_ACCESS(_res_ptr);
10891         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10892         FREE((void*)_res);
10893         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10894 }
10895
10896 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10897         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10898         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10899         return (uint32_t)ret_conv;
10900 }
10901 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10902         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10903         uint32_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10904         return ret_val;
10905 }
10906
10907 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10908         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10909         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10910         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10911         return (uint32_t)ret_conv;
10912 }
10913
10914 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10915         LDKTxCreationKeys o_conv;
10916         o_conv.inner = (void*)(o & (~1));
10917         o_conv.is_owned = (o & 1) || (o == 0);
10918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10919         o_conv = TxCreationKeys_clone(&o_conv);
10920         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10921         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10922         return (uint32_t)ret_conv;
10923 }
10924
10925 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10926         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10927         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10928         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10929         return (uint32_t)ret_conv;
10930 }
10931
10932 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10933         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10934         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10935         return ret_val;
10936 }
10937
10938 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10939         if ((_res & 1) != 0) return;
10940         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10941         CHECK_ACCESS(_res_ptr);
10942         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10943         FREE((void*)_res);
10944         CResult_TxCreationKeysErrorZ_free(_res_conv);
10945 }
10946
10947 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
10948         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10949         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
10950         return (uint32_t)ret_conv;
10951 }
10952 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
10953         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
10954         uint32_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
10955         return ret_val;
10956 }
10957
10958 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
10959         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10960         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10961         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10962         return (uint32_t)ret_conv;
10963 }
10964
10965 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
10966         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10967         *ret_copy = COption_u32Z_some(o);
10968         uint32_t ret_ref = (uintptr_t)ret_copy;
10969         return ret_ref;
10970 }
10971
10972 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
10973         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10974         *ret_copy = COption_u32Z_none();
10975         uint32_t ret_ref = (uintptr_t)ret_copy;
10976         return ret_ref;
10977 }
10978
10979 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
10980         if ((_res & 1) != 0) return;
10981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10982         CHECK_ACCESS(_res_ptr);
10983         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10984         FREE((void*)_res);
10985         COption_u32Z_free(_res_conv);
10986 }
10987
10988 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
10989         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10990         *ret_copy = COption_u32Z_clone(arg);
10991 uint32_t ret_ref = (uintptr_t)ret_copy;
10992         return ret_ref;
10993 }
10994 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
10995         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
10996         uint32_t ret_val = COption_u32Z_clone_ptr(arg_conv);
10997         return ret_val;
10998 }
10999
11000 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11001         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11002         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11003         *ret_copy = COption_u32Z_clone(orig_conv);
11004         uint32_t ret_ref = (uintptr_t)ret_copy;
11005         return ret_ref;
11006 }
11007
11008 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11009         LDKHTLCOutputInCommitment o_conv;
11010         o_conv.inner = (void*)(o & (~1));
11011         o_conv.is_owned = (o & 1) || (o == 0);
11012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11013         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11014         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11015         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11016         return (uint32_t)ret_conv;
11017 }
11018
11019 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11020         LDKDecodeError e_conv;
11021         e_conv.inner = (void*)(e & (~1));
11022         e_conv.is_owned = (e & 1) || (e == 0);
11023         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11024         e_conv = DecodeError_clone(&e_conv);
11025         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11026         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11027         return (uint32_t)ret_conv;
11028 }
11029
11030 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11031         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11032         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11033         return ret_val;
11034 }
11035
11036 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11037         if ((_res & 1) != 0) return;
11038         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11039         CHECK_ACCESS(_res_ptr);
11040         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11041         FREE((void*)_res);
11042         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11043 }
11044
11045 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11046         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11047         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11048         return (uint32_t)ret_conv;
11049 }
11050 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11051         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11052         uint32_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11053         return ret_val;
11054 }
11055
11056 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11057         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11058         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11059         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11060         return (uint32_t)ret_conv;
11061 }
11062
11063 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11064         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11065         return ret_conv;
11066 }
11067
11068 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11069         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11070         return ret_conv;
11071 }
11072
11073 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11074         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11075         COption_NoneZ_free(_res_conv);
11076 }
11077
11078 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11079         LDKCounterpartyChannelTransactionParameters o_conv;
11080         o_conv.inner = (void*)(o & (~1));
11081         o_conv.is_owned = (o & 1) || (o == 0);
11082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11083         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11084         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11085         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11086         return (uint32_t)ret_conv;
11087 }
11088
11089 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11090         LDKDecodeError e_conv;
11091         e_conv.inner = (void*)(e & (~1));
11092         e_conv.is_owned = (e & 1) || (e == 0);
11093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11094         e_conv = DecodeError_clone(&e_conv);
11095         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11096         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11097         return (uint32_t)ret_conv;
11098 }
11099
11100 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11101         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11102         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11103         return ret_val;
11104 }
11105
11106 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11107         if ((_res & 1) != 0) return;
11108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11109         CHECK_ACCESS(_res_ptr);
11110         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11111         FREE((void*)_res);
11112         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11113 }
11114
11115 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11116         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11117         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11118         return (uint32_t)ret_conv;
11119 }
11120 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11121         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11122         uint32_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11123         return ret_val;
11124 }
11125
11126 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11127         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11128         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11129         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11130         return (uint32_t)ret_conv;
11131 }
11132
11133 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11134         LDKChannelTransactionParameters o_conv;
11135         o_conv.inner = (void*)(o & (~1));
11136         o_conv.is_owned = (o & 1) || (o == 0);
11137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11138         o_conv = ChannelTransactionParameters_clone(&o_conv);
11139         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11140         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11141         return (uint32_t)ret_conv;
11142 }
11143
11144 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11145         LDKDecodeError e_conv;
11146         e_conv.inner = (void*)(e & (~1));
11147         e_conv.is_owned = (e & 1) || (e == 0);
11148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11149         e_conv = DecodeError_clone(&e_conv);
11150         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11151         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11152         return (uint32_t)ret_conv;
11153 }
11154
11155 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11156         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11157         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11158         return ret_val;
11159 }
11160
11161 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11162         if ((_res & 1) != 0) return;
11163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11164         CHECK_ACCESS(_res_ptr);
11165         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11166         FREE((void*)_res);
11167         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11168 }
11169
11170 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11171         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11172         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11173         return (uint32_t)ret_conv;
11174 }
11175 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11176         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11177         uint32_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11178         return ret_val;
11179 }
11180
11181 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11182         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11183         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11184         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11185         return (uint32_t)ret_conv;
11186 }
11187
11188 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11189         LDKCVec_SignatureZ _res_constr;
11190         _res_constr.datalen = _res->arr_len;
11191         if (_res_constr.datalen > 0)
11192                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11193         else
11194                 _res_constr.data = NULL;
11195         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11196         for (size_t m = 0; m < _res_constr.datalen; m++) {
11197                 int8_tArray _res_conv_12 = _res_vals[m];
11198                 LDKSignature _res_conv_12_ref;
11199                 CHECK(_res_conv_12->arr_len == 64);
11200                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11201                 _res_constr.data[m] = _res_conv_12_ref;
11202         }
11203         CVec_SignatureZ_free(_res_constr);
11204 }
11205
11206 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11207         LDKHolderCommitmentTransaction o_conv;
11208         o_conv.inner = (void*)(o & (~1));
11209         o_conv.is_owned = (o & 1) || (o == 0);
11210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11211         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11212         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11213         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11214         return (uint32_t)ret_conv;
11215 }
11216
11217 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11218         LDKDecodeError e_conv;
11219         e_conv.inner = (void*)(e & (~1));
11220         e_conv.is_owned = (e & 1) || (e == 0);
11221         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11222         e_conv = DecodeError_clone(&e_conv);
11223         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11224         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11225         return (uint32_t)ret_conv;
11226 }
11227
11228 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11229         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11230         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11231         return ret_val;
11232 }
11233
11234 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11235         if ((_res & 1) != 0) return;
11236         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11237         CHECK_ACCESS(_res_ptr);
11238         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11239         FREE((void*)_res);
11240         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11241 }
11242
11243 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11244         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11245         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11246         return (uint32_t)ret_conv;
11247 }
11248 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11249         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11250         uint32_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11251         return ret_val;
11252 }
11253
11254 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11255         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11256         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11257         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11258         return (uint32_t)ret_conv;
11259 }
11260
11261 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11262         LDKBuiltCommitmentTransaction o_conv;
11263         o_conv.inner = (void*)(o & (~1));
11264         o_conv.is_owned = (o & 1) || (o == 0);
11265         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11266         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11267         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11268         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11269         return (uint32_t)ret_conv;
11270 }
11271
11272 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11273         LDKDecodeError e_conv;
11274         e_conv.inner = (void*)(e & (~1));
11275         e_conv.is_owned = (e & 1) || (e == 0);
11276         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11277         e_conv = DecodeError_clone(&e_conv);
11278         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11279         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11280         return (uint32_t)ret_conv;
11281 }
11282
11283 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11284         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11285         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11286         return ret_val;
11287 }
11288
11289 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11290         if ((_res & 1) != 0) return;
11291         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11292         CHECK_ACCESS(_res_ptr);
11293         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11294         FREE((void*)_res);
11295         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11296 }
11297
11298 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11299         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11300         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11301         return (uint32_t)ret_conv;
11302 }
11303 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11304         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11305         uint32_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11306         return ret_val;
11307 }
11308
11309 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11310         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11311         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11312         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11313         return (uint32_t)ret_conv;
11314 }
11315
11316 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11317         LDKTrustedClosingTransaction o_conv;
11318         o_conv.inner = (void*)(o & (~1));
11319         o_conv.is_owned = (o & 1) || (o == 0);
11320         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11321         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11322         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11323         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11324         return (uint32_t)ret_conv;
11325 }
11326
11327 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11328         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11329         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11330         return (uint32_t)ret_conv;
11331 }
11332
11333 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11334         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11335         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11336         return ret_val;
11337 }
11338
11339 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11340         if ((_res & 1) != 0) return;
11341         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11342         CHECK_ACCESS(_res_ptr);
11343         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11344         FREE((void*)_res);
11345         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11346 }
11347
11348 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11349         LDKCommitmentTransaction o_conv;
11350         o_conv.inner = (void*)(o & (~1));
11351         o_conv.is_owned = (o & 1) || (o == 0);
11352         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11353         o_conv = CommitmentTransaction_clone(&o_conv);
11354         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11355         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11356         return (uint32_t)ret_conv;
11357 }
11358
11359 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11360         LDKDecodeError e_conv;
11361         e_conv.inner = (void*)(e & (~1));
11362         e_conv.is_owned = (e & 1) || (e == 0);
11363         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11364         e_conv = DecodeError_clone(&e_conv);
11365         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11366         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11367         return (uint32_t)ret_conv;
11368 }
11369
11370 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11371         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11372         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11373         return ret_val;
11374 }
11375
11376 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11377         if ((_res & 1) != 0) return;
11378         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11379         CHECK_ACCESS(_res_ptr);
11380         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11381         FREE((void*)_res);
11382         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11383 }
11384
11385 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11386         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11387         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11388         return (uint32_t)ret_conv;
11389 }
11390 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11391         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11392         uint32_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11393         return ret_val;
11394 }
11395
11396 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11397         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11398         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11399         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11400         return (uint32_t)ret_conv;
11401 }
11402
11403 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11404         LDKTrustedCommitmentTransaction o_conv;
11405         o_conv.inner = (void*)(o & (~1));
11406         o_conv.is_owned = (o & 1) || (o == 0);
11407         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11408         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11409         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11410         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11411         return (uint32_t)ret_conv;
11412 }
11413
11414 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11415         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11416         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11417         return (uint32_t)ret_conv;
11418 }
11419
11420 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11421         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11422         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11423         return ret_val;
11424 }
11425
11426 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11427         if ((_res & 1) != 0) return;
11428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11429         CHECK_ACCESS(_res_ptr);
11430         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11431         FREE((void*)_res);
11432         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11433 }
11434
11435 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11436         LDKCVec_SignatureZ o_constr;
11437         o_constr.datalen = o->arr_len;
11438         if (o_constr.datalen > 0)
11439                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11440         else
11441                 o_constr.data = NULL;
11442         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11443         for (size_t m = 0; m < o_constr.datalen; m++) {
11444                 int8_tArray o_conv_12 = o_vals[m];
11445                 LDKSignature o_conv_12_ref;
11446                 CHECK(o_conv_12->arr_len == 64);
11447                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11448                 o_constr.data[m] = o_conv_12_ref;
11449         }
11450         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11451         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11452         return (uint32_t)ret_conv;
11453 }
11454
11455 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11456         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11457         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11458         return (uint32_t)ret_conv;
11459 }
11460
11461 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11462         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11463         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11464         return ret_val;
11465 }
11466
11467 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11468         if ((_res & 1) != 0) return;
11469         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11470         CHECK_ACCESS(_res_ptr);
11471         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11472         FREE((void*)_res);
11473         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11474 }
11475
11476 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11477         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11478         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11479         return (uint32_t)ret_conv;
11480 }
11481 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11482         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11483         uint32_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11484         return ret_val;
11485 }
11486
11487 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11488         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11489         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11490         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11491         return (uint32_t)ret_conv;
11492 }
11493
11494 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11495         LDKShutdownScript o_conv;
11496         o_conv.inner = (void*)(o & (~1));
11497         o_conv.is_owned = (o & 1) || (o == 0);
11498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11499         o_conv = ShutdownScript_clone(&o_conv);
11500         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11501         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11502         return (uint32_t)ret_conv;
11503 }
11504
11505 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11506         LDKDecodeError e_conv;
11507         e_conv.inner = (void*)(e & (~1));
11508         e_conv.is_owned = (e & 1) || (e == 0);
11509         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11510         e_conv = DecodeError_clone(&e_conv);
11511         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11512         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11513         return (uint32_t)ret_conv;
11514 }
11515
11516 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11517         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11518         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11519         return ret_val;
11520 }
11521
11522 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11523         if ((_res & 1) != 0) return;
11524         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11525         CHECK_ACCESS(_res_ptr);
11526         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11527         FREE((void*)_res);
11528         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11529 }
11530
11531 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11532         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11533         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11534         return (uint32_t)ret_conv;
11535 }
11536 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11537         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11538         uint32_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11539         return ret_val;
11540 }
11541
11542 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11543         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11544         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11545         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11546         return (uint32_t)ret_conv;
11547 }
11548
11549 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11550         LDKShutdownScript o_conv;
11551         o_conv.inner = (void*)(o & (~1));
11552         o_conv.is_owned = (o & 1) || (o == 0);
11553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11554         o_conv = ShutdownScript_clone(&o_conv);
11555         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11556         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11557         return (uint32_t)ret_conv;
11558 }
11559
11560 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11561         LDKInvalidShutdownScript e_conv;
11562         e_conv.inner = (void*)(e & (~1));
11563         e_conv.is_owned = (e & 1) || (e == 0);
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11565         e_conv = InvalidShutdownScript_clone(&e_conv);
11566         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11567         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11568         return (uint32_t)ret_conv;
11569 }
11570
11571 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11572         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11573         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11574         return ret_val;
11575 }
11576
11577 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11578         if ((_res & 1) != 0) return;
11579         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11580         CHECK_ACCESS(_res_ptr);
11581         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11582         FREE((void*)_res);
11583         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11584 }
11585
11586 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11587         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11588         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11589         return (uint32_t)ret_conv;
11590 }
11591 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11592         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11593         uint32_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11594         return ret_val;
11595 }
11596
11597 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11598         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11599         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11600         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11601         return (uint32_t)ret_conv;
11602 }
11603
11604 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11605         LDKRouteHop o_conv;
11606         o_conv.inner = (void*)(o & (~1));
11607         o_conv.is_owned = (o & 1) || (o == 0);
11608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11609         o_conv = RouteHop_clone(&o_conv);
11610         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11611         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11612         return (uint32_t)ret_conv;
11613 }
11614
11615 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11616         LDKDecodeError e_conv;
11617         e_conv.inner = (void*)(e & (~1));
11618         e_conv.is_owned = (e & 1) || (e == 0);
11619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11620         e_conv = DecodeError_clone(&e_conv);
11621         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11622         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11623         return (uint32_t)ret_conv;
11624 }
11625
11626 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11627         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11628         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11629         return ret_val;
11630 }
11631
11632 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11633         if ((_res & 1) != 0) return;
11634         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11635         CHECK_ACCESS(_res_ptr);
11636         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11637         FREE((void*)_res);
11638         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11639 }
11640
11641 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11642         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11643         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11644         return (uint32_t)ret_conv;
11645 }
11646 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11647         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11648         uint32_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11649         return ret_val;
11650 }
11651
11652 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11653         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11654         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11655         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11656         return (uint32_t)ret_conv;
11657 }
11658
11659 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11660         LDKCVec_RouteHopZ _res_constr;
11661         _res_constr.datalen = _res->arr_len;
11662         if (_res_constr.datalen > 0)
11663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11664         else
11665                 _res_constr.data = NULL;
11666         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11667         for (size_t k = 0; k < _res_constr.datalen; k++) {
11668                 uint32_t _res_conv_10 = _res_vals[k];
11669                 LDKRouteHop _res_conv_10_conv;
11670                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11671                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11672                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11673                 _res_constr.data[k] = _res_conv_10_conv;
11674         }
11675         CVec_RouteHopZ_free(_res_constr);
11676 }
11677
11678 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11679         LDKCVec_CVec_RouteHopZZ _res_constr;
11680         _res_constr.datalen = _res->arr_len;
11681         if (_res_constr.datalen > 0)
11682                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11683         else
11684                 _res_constr.data = NULL;
11685         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11686         for (size_t m = 0; m < _res_constr.datalen; m++) {
11687                 uint32_tArray _res_conv_12 = _res_vals[m];
11688                 LDKCVec_RouteHopZ _res_conv_12_constr;
11689                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11690                 if (_res_conv_12_constr.datalen > 0)
11691                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11692                 else
11693                         _res_conv_12_constr.data = NULL;
11694                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11695                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11696                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11697                         LDKRouteHop _res_conv_12_conv_10_conv;
11698                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11699                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11700                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11701                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11702                 }
11703                 _res_constr.data[m] = _res_conv_12_constr;
11704         }
11705         CVec_CVec_RouteHopZZ_free(_res_constr);
11706 }
11707
11708 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11709         LDKRoute o_conv;
11710         o_conv.inner = (void*)(o & (~1));
11711         o_conv.is_owned = (o & 1) || (o == 0);
11712         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11713         o_conv = Route_clone(&o_conv);
11714         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11715         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11716         return (uint32_t)ret_conv;
11717 }
11718
11719 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11720         LDKDecodeError e_conv;
11721         e_conv.inner = (void*)(e & (~1));
11722         e_conv.is_owned = (e & 1) || (e == 0);
11723         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11724         e_conv = DecodeError_clone(&e_conv);
11725         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11726         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11727         return (uint32_t)ret_conv;
11728 }
11729
11730 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11731         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11732         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11733         return ret_val;
11734 }
11735
11736 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11737         if ((_res & 1) != 0) return;
11738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11739         CHECK_ACCESS(_res_ptr);
11740         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11741         FREE((void*)_res);
11742         CResult_RouteDecodeErrorZ_free(_res_conv);
11743 }
11744
11745 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11746         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11747         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11748         return (uint32_t)ret_conv;
11749 }
11750 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11751         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11752         uint32_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11753         return ret_val;
11754 }
11755
11756 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11757         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11758         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11759         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11760         return (uint32_t)ret_conv;
11761 }
11762
11763 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11764         LDKRouteParameters o_conv;
11765         o_conv.inner = (void*)(o & (~1));
11766         o_conv.is_owned = (o & 1) || (o == 0);
11767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11768         o_conv = RouteParameters_clone(&o_conv);
11769         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11770         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11771         return (uint32_t)ret_conv;
11772 }
11773
11774 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11775         LDKDecodeError e_conv;
11776         e_conv.inner = (void*)(e & (~1));
11777         e_conv.is_owned = (e & 1) || (e == 0);
11778         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11779         e_conv = DecodeError_clone(&e_conv);
11780         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11781         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11782         return (uint32_t)ret_conv;
11783 }
11784
11785 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11786         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11787         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11788         return ret_val;
11789 }
11790
11791 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11792         if ((_res & 1) != 0) return;
11793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11794         CHECK_ACCESS(_res_ptr);
11795         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11796         FREE((void*)_res);
11797         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11798 }
11799
11800 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11801         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11802         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11803         return (uint32_t)ret_conv;
11804 }
11805 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11806         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11807         uint32_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11808         return ret_val;
11809 }
11810
11811 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11812         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11813         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11814         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11815         return (uint32_t)ret_conv;
11816 }
11817
11818 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11819         LDKCVec_RouteHintZ _res_constr;
11820         _res_constr.datalen = _res->arr_len;
11821         if (_res_constr.datalen > 0)
11822                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11823         else
11824                 _res_constr.data = NULL;
11825         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11826         for (size_t l = 0; l < _res_constr.datalen; l++) {
11827                 uint32_t _res_conv_11 = _res_vals[l];
11828                 LDKRouteHint _res_conv_11_conv;
11829                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11830                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11831                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11832                 _res_constr.data[l] = _res_conv_11_conv;
11833         }
11834         CVec_RouteHintZ_free(_res_constr);
11835 }
11836
11837 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11838         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11839         *ret_copy = COption_u64Z_some(o);
11840         uint32_t ret_ref = (uintptr_t)ret_copy;
11841         return ret_ref;
11842 }
11843
11844 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11845         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11846         *ret_copy = COption_u64Z_none();
11847         uint32_t ret_ref = (uintptr_t)ret_copy;
11848         return ret_ref;
11849 }
11850
11851 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11852         if ((_res & 1) != 0) return;
11853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11854         CHECK_ACCESS(_res_ptr);
11855         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11856         FREE((void*)_res);
11857         COption_u64Z_free(_res_conv);
11858 }
11859
11860 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11861         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11862         *ret_copy = COption_u64Z_clone(arg);
11863 uint32_t ret_ref = (uintptr_t)ret_copy;
11864         return ret_ref;
11865 }
11866 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11867         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11868         uint32_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11869         return ret_val;
11870 }
11871
11872 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11873         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11874         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11875         *ret_copy = COption_u64Z_clone(orig_conv);
11876         uint32_t ret_ref = (uintptr_t)ret_copy;
11877         return ret_ref;
11878 }
11879
11880 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11881         LDKPaymentParameters o_conv;
11882         o_conv.inner = (void*)(o & (~1));
11883         o_conv.is_owned = (o & 1) || (o == 0);
11884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11885         o_conv = PaymentParameters_clone(&o_conv);
11886         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11887         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11888         return (uint32_t)ret_conv;
11889 }
11890
11891 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11892         LDKDecodeError e_conv;
11893         e_conv.inner = (void*)(e & (~1));
11894         e_conv.is_owned = (e & 1) || (e == 0);
11895         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11896         e_conv = DecodeError_clone(&e_conv);
11897         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11898         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11899         return (uint32_t)ret_conv;
11900 }
11901
11902 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11903         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11904         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11905         return ret_val;
11906 }
11907
11908 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11909         if ((_res & 1) != 0) return;
11910         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11911         CHECK_ACCESS(_res_ptr);
11912         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11913         FREE((void*)_res);
11914         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11915 }
11916
11917 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11918         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11919         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11920         return (uint32_t)ret_conv;
11921 }
11922 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11923         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11924         uint32_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11925         return ret_val;
11926 }
11927
11928 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11929         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11930         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11931         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11932         return (uint32_t)ret_conv;
11933 }
11934
11935 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11936         LDKCVec_RouteHintHopZ _res_constr;
11937         _res_constr.datalen = _res->arr_len;
11938         if (_res_constr.datalen > 0)
11939                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11940         else
11941                 _res_constr.data = NULL;
11942         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11943         for (size_t o = 0; o < _res_constr.datalen; o++) {
11944                 uint32_t _res_conv_14 = _res_vals[o];
11945                 LDKRouteHintHop _res_conv_14_conv;
11946                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11947                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11948                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11949                 _res_constr.data[o] = _res_conv_14_conv;
11950         }
11951         CVec_RouteHintHopZ_free(_res_constr);
11952 }
11953
11954 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11955         LDKRouteHint o_conv;
11956         o_conv.inner = (void*)(o & (~1));
11957         o_conv.is_owned = (o & 1) || (o == 0);
11958         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11959         o_conv = RouteHint_clone(&o_conv);
11960         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11961         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11962         return (uint32_t)ret_conv;
11963 }
11964
11965 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11966         LDKDecodeError e_conv;
11967         e_conv.inner = (void*)(e & (~1));
11968         e_conv.is_owned = (e & 1) || (e == 0);
11969         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11970         e_conv = DecodeError_clone(&e_conv);
11971         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11972         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11973         return (uint32_t)ret_conv;
11974 }
11975
11976 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11977         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11978         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11979         return ret_val;
11980 }
11981
11982 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11983         if ((_res & 1) != 0) return;
11984         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11985         CHECK_ACCESS(_res_ptr);
11986         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11987         FREE((void*)_res);
11988         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11989 }
11990
11991 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11992         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11993         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11994         return (uint32_t)ret_conv;
11995 }
11996 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11997         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11998         uint32_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11999         return ret_val;
12000 }
12001
12002 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12003         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12004         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12005         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12006         return (uint32_t)ret_conv;
12007 }
12008
12009 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12010         LDKRouteHintHop o_conv;
12011         o_conv.inner = (void*)(o & (~1));
12012         o_conv.is_owned = (o & 1) || (o == 0);
12013         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12014         o_conv = RouteHintHop_clone(&o_conv);
12015         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12016         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12017         return (uint32_t)ret_conv;
12018 }
12019
12020 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12021         LDKDecodeError e_conv;
12022         e_conv.inner = (void*)(e & (~1));
12023         e_conv.is_owned = (e & 1) || (e == 0);
12024         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12025         e_conv = DecodeError_clone(&e_conv);
12026         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12027         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12028         return (uint32_t)ret_conv;
12029 }
12030
12031 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12032         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12033         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12034         return ret_val;
12035 }
12036
12037 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12038         if ((_res & 1) != 0) return;
12039         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12040         CHECK_ACCESS(_res_ptr);
12041         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12042         FREE((void*)_res);
12043         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12044 }
12045
12046 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12047         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12048         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12049         return (uint32_t)ret_conv;
12050 }
12051 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12052         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12053         uint32_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12054         return ret_val;
12055 }
12056
12057 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12058         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12059         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12060         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12061         return (uint32_t)ret_conv;
12062 }
12063
12064 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12065         LDKCVec_ChannelDetailsZ _res_constr;
12066         _res_constr.datalen = _res->arr_len;
12067         if (_res_constr.datalen > 0)
12068                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12069         else
12070                 _res_constr.data = NULL;
12071         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12072         for (size_t q = 0; q < _res_constr.datalen; q++) {
12073                 uint32_t _res_conv_16 = _res_vals[q];
12074                 LDKChannelDetails _res_conv_16_conv;
12075                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12076                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12077                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12078                 _res_constr.data[q] = _res_conv_16_conv;
12079         }
12080         CVec_ChannelDetailsZ_free(_res_constr);
12081 }
12082
12083 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12084         LDKRoute o_conv;
12085         o_conv.inner = (void*)(o & (~1));
12086         o_conv.is_owned = (o & 1) || (o == 0);
12087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12088         o_conv = Route_clone(&o_conv);
12089         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12090         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12091         return (uint32_t)ret_conv;
12092 }
12093
12094 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12095         LDKLightningError e_conv;
12096         e_conv.inner = (void*)(e & (~1));
12097         e_conv.is_owned = (e & 1) || (e == 0);
12098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12099         e_conv = LightningError_clone(&e_conv);
12100         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12101         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12102         return (uint32_t)ret_conv;
12103 }
12104
12105 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12106         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12107         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
12108         return ret_val;
12109 }
12110
12111 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12112         if ((_res & 1) != 0) return;
12113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12114         CHECK_ACCESS(_res_ptr);
12115         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12116         FREE((void*)_res);
12117         CResult_RouteLightningErrorZ_free(_res_conv);
12118 }
12119
12120 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12121         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12122         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12123         return (uint32_t)ret_conv;
12124 }
12125 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12126         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12127         uint32_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12128         return ret_val;
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12132         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12133         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12134         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12135         return (uint32_t)ret_conv;
12136 }
12137
12138 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12139         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12140         CHECK_ACCESS(o_ptr);
12141         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12142         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12143         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12144         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12145         return (uint32_t)ret_conv;
12146 }
12147
12148 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12149         LDKAccessError e_conv = LDKAccessError_from_js(e);
12150         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12151         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12152         return (uint32_t)ret_conv;
12153 }
12154
12155 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12156         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12157         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12158         return ret_val;
12159 }
12160
12161 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
12162         if ((_res & 1) != 0) return;
12163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12164         CHECK_ACCESS(_res_ptr);
12165         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12166         FREE((void*)_res);
12167         CResult_TxOutAccessErrorZ_free(_res_conv);
12168 }
12169
12170 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12171         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12172         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12173         return (uint32_t)ret_conv;
12174 }
12175 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12176         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12177         uint32_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12178         return ret_val;
12179 }
12180
12181 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12182         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12183         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12184         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12185         return (uint32_t)ret_conv;
12186 }
12187
12188 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12189         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12190         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12191         return ((uint32_t)ret_conv);
12192 }
12193 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12194         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12195         uint32_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12196         return ret_val;
12197 }
12198
12199 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12200         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12201         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12202         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12203         return ((uint32_t)ret_conv);
12204 }
12205
12206 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12207         LDKTransaction b_ref;
12208         b_ref.datalen = b->arr_len;
12209         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12210         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12211         b_ref.data_is_owned = true;
12212         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12213         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12214         return ((uint32_t)ret_conv);
12215 }
12216
12217 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12218         if ((_res & 1) != 0) return;
12219         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12220         CHECK_ACCESS(_res_ptr);
12221         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12222         FREE((void*)_res);
12223         C2Tuple_usizeTransactionZ_free(_res_conv);
12224 }
12225
12226 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12227         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12228         _res_constr.datalen = _res->arr_len;
12229         if (_res_constr.datalen > 0)
12230                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12231         else
12232                 _res_constr.data = NULL;
12233         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12234         for (size_t c = 0; c < _res_constr.datalen; c++) {
12235                 uint32_t _res_conv_28 = _res_vals[c];
12236                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12237                 CHECK_ACCESS(_res_conv_28_ptr);
12238                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12239                 FREE((void*)_res_conv_28);
12240                 _res_constr.data[c] = _res_conv_28_conv;
12241         }
12242         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12243 }
12244
12245 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12246         LDKCVec_TxidZ _res_constr;
12247         _res_constr.datalen = _res->arr_len;
12248         if (_res_constr.datalen > 0)
12249                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12250         else
12251                 _res_constr.data = NULL;
12252         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12253         for (size_t m = 0; m < _res_constr.datalen; m++) {
12254                 int8_tArray _res_conv_12 = _res_vals[m];
12255                 LDKThirtyTwoBytes _res_conv_12_ref;
12256                 CHECK(_res_conv_12->arr_len == 32);
12257                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12258                 _res_constr.data[m] = _res_conv_12_ref;
12259         }
12260         CVec_TxidZ_free(_res_constr);
12261 }
12262
12263 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12264         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12265         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12266         return (uint32_t)ret_conv;
12267 }
12268
12269 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12270         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12271         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12272         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12273         return (uint32_t)ret_conv;
12274 }
12275
12276 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12277         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12278         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12279         return ret_val;
12280 }
12281
12282 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12283         if ((_res & 1) != 0) return;
12284         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12285         CHECK_ACCESS(_res_ptr);
12286         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12287         FREE((void*)_res);
12288         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12289 }
12290
12291 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12292         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12293         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12294         return (uint32_t)ret_conv;
12295 }
12296 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12297         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12298         uint32_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12299         return ret_val;
12300 }
12301
12302 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12303         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12304         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12305         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12306         return (uint32_t)ret_conv;
12307 }
12308
12309 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12310         LDKCVec_MonitorEventZ _res_constr;
12311         _res_constr.datalen = _res->arr_len;
12312         if (_res_constr.datalen > 0)
12313                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12314         else
12315                 _res_constr.data = NULL;
12316         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12317         for (size_t o = 0; o < _res_constr.datalen; o++) {
12318                 uint32_t _res_conv_14 = _res_vals[o];
12319                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12320                 CHECK_ACCESS(_res_conv_14_ptr);
12321                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12322                 FREE((void*)_res_conv_14);
12323                 _res_constr.data[o] = _res_conv_14_conv;
12324         }
12325         CVec_MonitorEventZ_free(_res_constr);
12326 }
12327
12328 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12329         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12330         CHECK_ACCESS(o_ptr);
12331         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12332         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12333         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12334         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12335         uint32_t ret_ref = (uintptr_t)ret_copy;
12336         return ret_ref;
12337 }
12338
12339 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12340         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12341         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12342         uint32_t ret_ref = (uintptr_t)ret_copy;
12343         return ret_ref;
12344 }
12345
12346 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12347         if ((_res & 1) != 0) return;
12348         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12349         CHECK_ACCESS(_res_ptr);
12350         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12351         FREE((void*)_res);
12352         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12353 }
12354
12355 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12356         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12357         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12358 uint32_t ret_ref = (uintptr_t)ret_copy;
12359         return ret_ref;
12360 }
12361 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12362         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12363         uint32_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12364         return ret_val;
12365 }
12366
12367 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12368         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12369         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12370         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12371         uint32_t ret_ref = (uintptr_t)ret_copy;
12372         return ret_ref;
12373 }
12374
12375 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12376         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12377         CHECK_ACCESS(o_ptr);
12378         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12379         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12380         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12381         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12382         uint32_t ret_ref = (uintptr_t)ret_copy;
12383         return ret_ref;
12384 }
12385
12386 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12387         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12388         *ret_copy = COption_ClosureReasonZ_none();
12389         uint32_t ret_ref = (uintptr_t)ret_copy;
12390         return ret_ref;
12391 }
12392
12393 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12394         if ((_res & 1) != 0) return;
12395         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12396         CHECK_ACCESS(_res_ptr);
12397         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12398         FREE((void*)_res);
12399         COption_ClosureReasonZ_free(_res_conv);
12400 }
12401
12402 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12403         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12404         *ret_copy = COption_ClosureReasonZ_clone(arg);
12405 uint32_t ret_ref = (uintptr_t)ret_copy;
12406         return ret_ref;
12407 }
12408 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12409         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12410         uint32_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12411         return ret_val;
12412 }
12413
12414 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12415         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12416         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12417         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12418         uint32_t ret_ref = (uintptr_t)ret_copy;
12419         return ret_ref;
12420 }
12421
12422 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12423         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12424         CHECK_ACCESS(o_ptr);
12425         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12426         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12427         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12428         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12429         return (uint32_t)ret_conv;
12430 }
12431
12432 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12433         LDKDecodeError e_conv;
12434         e_conv.inner = (void*)(e & (~1));
12435         e_conv.is_owned = (e & 1) || (e == 0);
12436         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12437         e_conv = DecodeError_clone(&e_conv);
12438         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12439         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12440         return (uint32_t)ret_conv;
12441 }
12442
12443 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12444         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12445         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12446         return ret_val;
12447 }
12448
12449 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12450         if ((_res & 1) != 0) return;
12451         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12452         CHECK_ACCESS(_res_ptr);
12453         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12454         FREE((void*)_res);
12455         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12456 }
12457
12458 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12459         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12460         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12461         return (uint32_t)ret_conv;
12462 }
12463 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12464         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12465         uint32_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12466         return ret_val;
12467 }
12468
12469 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12470         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12471         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12472         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12473         return (uint32_t)ret_conv;
12474 }
12475
12476 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12477         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12478         CHECK_ACCESS(o_ptr);
12479         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12480         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12481         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12482         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12483         uint32_t ret_ref = (uintptr_t)ret_copy;
12484         return ret_ref;
12485 }
12486
12487 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12488         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12489         *ret_copy = COption_NetworkUpdateZ_none();
12490         uint32_t ret_ref = (uintptr_t)ret_copy;
12491         return ret_ref;
12492 }
12493
12494 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12495         if ((_res & 1) != 0) return;
12496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12497         CHECK_ACCESS(_res_ptr);
12498         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12499         FREE((void*)_res);
12500         COption_NetworkUpdateZ_free(_res_conv);
12501 }
12502
12503 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12504         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12505         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12506 uint32_t ret_ref = (uintptr_t)ret_copy;
12507         return ret_ref;
12508 }
12509 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12510         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12511         uint32_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12512         return ret_val;
12513 }
12514
12515 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12516         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12517         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12518         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12519         uint32_t ret_ref = (uintptr_t)ret_copy;
12520         return ret_ref;
12521 }
12522
12523 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12524         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12525         _res_constr.datalen = _res->arr_len;
12526         if (_res_constr.datalen > 0)
12527                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12528         else
12529                 _res_constr.data = NULL;
12530         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12531         for (size_t b = 0; b < _res_constr.datalen; b++) {
12532                 uint32_t _res_conv_27 = _res_vals[b];
12533                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12534                 CHECK_ACCESS(_res_conv_27_ptr);
12535                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12536                 FREE((void*)_res_conv_27);
12537                 _res_constr.data[b] = _res_conv_27_conv;
12538         }
12539         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12540 }
12541
12542 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12543         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12544         CHECK_ACCESS(o_ptr);
12545         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12546         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12547         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12548         *ret_copy = COption_EventZ_some(o_conv);
12549         uint32_t ret_ref = (uintptr_t)ret_copy;
12550         return ret_ref;
12551 }
12552
12553 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12554         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12555         *ret_copy = COption_EventZ_none();
12556         uint32_t ret_ref = (uintptr_t)ret_copy;
12557         return ret_ref;
12558 }
12559
12560 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12561         if ((_res & 1) != 0) return;
12562         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12563         CHECK_ACCESS(_res_ptr);
12564         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12565         FREE((void*)_res);
12566         COption_EventZ_free(_res_conv);
12567 }
12568
12569 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12570         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12571         *ret_copy = COption_EventZ_clone(arg);
12572 uint32_t ret_ref = (uintptr_t)ret_copy;
12573         return ret_ref;
12574 }
12575 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12576         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12577         uint32_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12578         return ret_val;
12579 }
12580
12581 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12582         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12583         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12584         *ret_copy = COption_EventZ_clone(orig_conv);
12585         uint32_t ret_ref = (uintptr_t)ret_copy;
12586         return ret_ref;
12587 }
12588
12589 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12590         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12591         CHECK_ACCESS(o_ptr);
12592         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12593         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12594         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12595         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12596         return (uint32_t)ret_conv;
12597 }
12598
12599 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12600         LDKDecodeError e_conv;
12601         e_conv.inner = (void*)(e & (~1));
12602         e_conv.is_owned = (e & 1) || (e == 0);
12603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12604         e_conv = DecodeError_clone(&e_conv);
12605         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12606         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12607         return (uint32_t)ret_conv;
12608 }
12609
12610 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12611         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12612         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12613         return ret_val;
12614 }
12615
12616 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12617         if ((_res & 1) != 0) return;
12618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12619         CHECK_ACCESS(_res_ptr);
12620         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12621         FREE((void*)_res);
12622         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12623 }
12624
12625 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12626         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12627         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12628         return (uint32_t)ret_conv;
12629 }
12630 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12631         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12632         uint32_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12633         return ret_val;
12634 }
12635
12636 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12637         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12638         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12639         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12640         return (uint32_t)ret_conv;
12641 }
12642
12643 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12644         LDKCVec_MessageSendEventZ _res_constr;
12645         _res_constr.datalen = _res->arr_len;
12646         if (_res_constr.datalen > 0)
12647                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12648         else
12649                 _res_constr.data = NULL;
12650         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12651         for (size_t s = 0; s < _res_constr.datalen; s++) {
12652                 uint32_t _res_conv_18 = _res_vals[s];
12653                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12654                 CHECK_ACCESS(_res_conv_18_ptr);
12655                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12656                 FREE((void*)_res_conv_18);
12657                 _res_constr.data[s] = _res_conv_18_conv;
12658         }
12659         CVec_MessageSendEventZ_free(_res_constr);
12660 }
12661
12662 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12663         LDKFixedPenaltyScorer o_conv;
12664         o_conv.inner = (void*)(o & (~1));
12665         o_conv.is_owned = (o & 1) || (o == 0);
12666         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12667         o_conv = FixedPenaltyScorer_clone(&o_conv);
12668         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12669         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12670         return (uint32_t)ret_conv;
12671 }
12672
12673 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12674         LDKDecodeError e_conv;
12675         e_conv.inner = (void*)(e & (~1));
12676         e_conv.is_owned = (e & 1) || (e == 0);
12677         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12678         e_conv = DecodeError_clone(&e_conv);
12679         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12680         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12681         return (uint32_t)ret_conv;
12682 }
12683
12684 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12685         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12686         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12687         return ret_val;
12688 }
12689
12690 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12691         if ((_res & 1) != 0) return;
12692         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12693         CHECK_ACCESS(_res_ptr);
12694         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12695         FREE((void*)_res);
12696         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12697 }
12698
12699 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12700         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12701         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12702         return (uint32_t)ret_conv;
12703 }
12704 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12705         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12706         uint32_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12707         return ret_val;
12708 }
12709
12710 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12711         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12712         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12713         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12714         return (uint32_t)ret_conv;
12715 }
12716
12717 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12718         LDKScoringParameters o_conv;
12719         o_conv.inner = (void*)(o & (~1));
12720         o_conv.is_owned = (o & 1) || (o == 0);
12721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12722         o_conv = ScoringParameters_clone(&o_conv);
12723         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12724         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12725         return (uint32_t)ret_conv;
12726 }
12727
12728 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12729         LDKDecodeError e_conv;
12730         e_conv.inner = (void*)(e & (~1));
12731         e_conv.is_owned = (e & 1) || (e == 0);
12732         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12733         e_conv = DecodeError_clone(&e_conv);
12734         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12735         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12736         return (uint32_t)ret_conv;
12737 }
12738
12739 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12740         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12741         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12742         return ret_val;
12743 }
12744
12745 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12746         if ((_res & 1) != 0) return;
12747         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12748         CHECK_ACCESS(_res_ptr);
12749         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12750         FREE((void*)_res);
12751         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12752 }
12753
12754 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12755         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12756         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12757         return (uint32_t)ret_conv;
12758 }
12759 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12760         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12761         uint32_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12762         return ret_val;
12763 }
12764
12765 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12766         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12767         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12768         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12769         return (uint32_t)ret_conv;
12770 }
12771
12772 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12773         LDKScorer o_conv;
12774         o_conv.inner = (void*)(o & (~1));
12775         o_conv.is_owned = (o & 1) || (o == 0);
12776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12777         // WARNING: we need a move here but no clone is available for LDKScorer
12778         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12779         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12780         return (uint32_t)ret_conv;
12781 }
12782
12783 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12784         LDKDecodeError e_conv;
12785         e_conv.inner = (void*)(e & (~1));
12786         e_conv.is_owned = (e & 1) || (e == 0);
12787         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12788         e_conv = DecodeError_clone(&e_conv);
12789         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12790         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12791         return (uint32_t)ret_conv;
12792 }
12793
12794 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12795         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12796         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12797         return ret_val;
12798 }
12799
12800 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12801         if ((_res & 1) != 0) return;
12802         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12803         CHECK_ACCESS(_res_ptr);
12804         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12805         FREE((void*)_res);
12806         CResult_ScorerDecodeErrorZ_free(_res_conv);
12807 }
12808
12809 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
12810         LDKProbabilisticScorer o_conv;
12811         o_conv.inner = (void*)(o & (~1));
12812         o_conv.is_owned = (o & 1) || (o == 0);
12813         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12814         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
12815         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12816         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
12817         return (uint32_t)ret_conv;
12818 }
12819
12820 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
12821         LDKDecodeError e_conv;
12822         e_conv.inner = (void*)(e & (~1));
12823         e_conv.is_owned = (e & 1) || (e == 0);
12824         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12825         e_conv = DecodeError_clone(&e_conv);
12826         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12827         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
12828         return (uint32_t)ret_conv;
12829 }
12830
12831 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
12832         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
12833         jboolean ret_val = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
12834         return ret_val;
12835 }
12836
12837 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
12838         if ((_res & 1) != 0) return;
12839         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12840         CHECK_ACCESS(_res_ptr);
12841         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
12842         FREE((void*)_res);
12843         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
12844 }
12845
12846 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12847         LDKInitFeatures o_conv;
12848         o_conv.inner = (void*)(o & (~1));
12849         o_conv.is_owned = (o & 1) || (o == 0);
12850         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12851         o_conv = InitFeatures_clone(&o_conv);
12852         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12853         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12854         return (uint32_t)ret_conv;
12855 }
12856
12857 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12858         LDKDecodeError e_conv;
12859         e_conv.inner = (void*)(e & (~1));
12860         e_conv.is_owned = (e & 1) || (e == 0);
12861         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12862         e_conv = DecodeError_clone(&e_conv);
12863         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12864         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12865         return (uint32_t)ret_conv;
12866 }
12867
12868 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12869         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12870         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12871         return ret_val;
12872 }
12873
12874 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12875         if ((_res & 1) != 0) return;
12876         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12877         CHECK_ACCESS(_res_ptr);
12878         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12879         FREE((void*)_res);
12880         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12881 }
12882
12883 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12884         LDKChannelFeatures o_conv;
12885         o_conv.inner = (void*)(o & (~1));
12886         o_conv.is_owned = (o & 1) || (o == 0);
12887         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12888         o_conv = ChannelFeatures_clone(&o_conv);
12889         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12890         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12891         return (uint32_t)ret_conv;
12892 }
12893
12894 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12895         LDKDecodeError e_conv;
12896         e_conv.inner = (void*)(e & (~1));
12897         e_conv.is_owned = (e & 1) || (e == 0);
12898         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12899         e_conv = DecodeError_clone(&e_conv);
12900         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12901         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12902         return (uint32_t)ret_conv;
12903 }
12904
12905 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12906         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12907         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12908         return ret_val;
12909 }
12910
12911 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12912         if ((_res & 1) != 0) return;
12913         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12914         CHECK_ACCESS(_res_ptr);
12915         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12916         FREE((void*)_res);
12917         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12918 }
12919
12920 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12921         LDKNodeFeatures o_conv;
12922         o_conv.inner = (void*)(o & (~1));
12923         o_conv.is_owned = (o & 1) || (o == 0);
12924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12925         o_conv = NodeFeatures_clone(&o_conv);
12926         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12927         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12928         return (uint32_t)ret_conv;
12929 }
12930
12931 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12932         LDKDecodeError e_conv;
12933         e_conv.inner = (void*)(e & (~1));
12934         e_conv.is_owned = (e & 1) || (e == 0);
12935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12936         e_conv = DecodeError_clone(&e_conv);
12937         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12938         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12939         return (uint32_t)ret_conv;
12940 }
12941
12942 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12943         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12944         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12945         return ret_val;
12946 }
12947
12948 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12949         if ((_res & 1) != 0) return;
12950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12951         CHECK_ACCESS(_res_ptr);
12952         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12953         FREE((void*)_res);
12954         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12955 }
12956
12957 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12958         LDKInvoiceFeatures o_conv;
12959         o_conv.inner = (void*)(o & (~1));
12960         o_conv.is_owned = (o & 1) || (o == 0);
12961         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12962         o_conv = InvoiceFeatures_clone(&o_conv);
12963         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12964         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12965         return (uint32_t)ret_conv;
12966 }
12967
12968 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12969         LDKDecodeError e_conv;
12970         e_conv.inner = (void*)(e & (~1));
12971         e_conv.is_owned = (e & 1) || (e == 0);
12972         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12973         e_conv = DecodeError_clone(&e_conv);
12974         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12975         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12976         return (uint32_t)ret_conv;
12977 }
12978
12979 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12980         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12981         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12982         return ret_val;
12983 }
12984
12985 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12986         if ((_res & 1) != 0) return;
12987         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12988         CHECK_ACCESS(_res_ptr);
12989         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12990         FREE((void*)_res);
12991         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12992 }
12993
12994 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12995         LDKChannelTypeFeatures o_conv;
12996         o_conv.inner = (void*)(o & (~1));
12997         o_conv.is_owned = (o & 1) || (o == 0);
12998         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12999         o_conv = ChannelTypeFeatures_clone(&o_conv);
13000         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13001         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13002         return (uint32_t)ret_conv;
13003 }
13004
13005 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13006         LDKDecodeError e_conv;
13007         e_conv.inner = (void*)(e & (~1));
13008         e_conv.is_owned = (e & 1) || (e == 0);
13009         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13010         e_conv = DecodeError_clone(&e_conv);
13011         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13012         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13013         return (uint32_t)ret_conv;
13014 }
13015
13016 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13017         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13018         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13019         return ret_val;
13020 }
13021
13022 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13023         if ((_res & 1) != 0) return;
13024         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13025         CHECK_ACCESS(_res_ptr);
13026         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13027         FREE((void*)_res);
13028         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13029 }
13030
13031 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13032         LDKDelayedPaymentOutputDescriptor o_conv;
13033         o_conv.inner = (void*)(o & (~1));
13034         o_conv.is_owned = (o & 1) || (o == 0);
13035         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13036         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13037         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13038         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13039         return (uint32_t)ret_conv;
13040 }
13041
13042 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13043         LDKDecodeError e_conv;
13044         e_conv.inner = (void*)(e & (~1));
13045         e_conv.is_owned = (e & 1) || (e == 0);
13046         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13047         e_conv = DecodeError_clone(&e_conv);
13048         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13049         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13050         return (uint32_t)ret_conv;
13051 }
13052
13053 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13054         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13055         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13056         return ret_val;
13057 }
13058
13059 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13060         if ((_res & 1) != 0) return;
13061         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13062         CHECK_ACCESS(_res_ptr);
13063         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13064         FREE((void*)_res);
13065         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13066 }
13067
13068 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13069         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13070         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13071         return (uint32_t)ret_conv;
13072 }
13073 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13074         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13075         uint32_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13076         return ret_val;
13077 }
13078
13079 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13080         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13081         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13082         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13083         return (uint32_t)ret_conv;
13084 }
13085
13086 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13087         LDKStaticPaymentOutputDescriptor o_conv;
13088         o_conv.inner = (void*)(o & (~1));
13089         o_conv.is_owned = (o & 1) || (o == 0);
13090         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13091         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13092         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13093         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13094         return (uint32_t)ret_conv;
13095 }
13096
13097 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13098         LDKDecodeError e_conv;
13099         e_conv.inner = (void*)(e & (~1));
13100         e_conv.is_owned = (e & 1) || (e == 0);
13101         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13102         e_conv = DecodeError_clone(&e_conv);
13103         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13104         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13105         return (uint32_t)ret_conv;
13106 }
13107
13108 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13109         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13110         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13111         return ret_val;
13112 }
13113
13114 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13115         if ((_res & 1) != 0) return;
13116         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13117         CHECK_ACCESS(_res_ptr);
13118         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13119         FREE((void*)_res);
13120         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13121 }
13122
13123 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13124         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13125         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13126         return (uint32_t)ret_conv;
13127 }
13128 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13129         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13130         uint32_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13131         return ret_val;
13132 }
13133
13134 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13135         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13136         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13137         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13138         return (uint32_t)ret_conv;
13139 }
13140
13141 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13142         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13143         CHECK_ACCESS(o_ptr);
13144         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13145         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
13146         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13147         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13148         return (uint32_t)ret_conv;
13149 }
13150
13151 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13152         LDKDecodeError e_conv;
13153         e_conv.inner = (void*)(e & (~1));
13154         e_conv.is_owned = (e & 1) || (e == 0);
13155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13156         e_conv = DecodeError_clone(&e_conv);
13157         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13158         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13159         return (uint32_t)ret_conv;
13160 }
13161
13162 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13163         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13164         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13165         return ret_val;
13166 }
13167
13168 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13169         if ((_res & 1) != 0) return;
13170         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13171         CHECK_ACCESS(_res_ptr);
13172         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13173         FREE((void*)_res);
13174         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13175 }
13176
13177 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13178         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13179         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13180         return (uint32_t)ret_conv;
13181 }
13182 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13183         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13184         uint32_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13185         return ret_val;
13186 }
13187
13188 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13189         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13190         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13191         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13192         return (uint32_t)ret_conv;
13193 }
13194
13195 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13196         LDKCVec_PaymentPreimageZ _res_constr;
13197         _res_constr.datalen = _res->arr_len;
13198         if (_res_constr.datalen > 0)
13199                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13200         else
13201                 _res_constr.data = NULL;
13202         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13203         for (size_t m = 0; m < _res_constr.datalen; m++) {
13204                 int8_tArray _res_conv_12 = _res_vals[m];
13205                 LDKThirtyTwoBytes _res_conv_12_ref;
13206                 CHECK(_res_conv_12->arr_len == 32);
13207                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13208                 _res_constr.data[m] = _res_conv_12_ref;
13209         }
13210         CVec_PaymentPreimageZ_free(_res_constr);
13211 }
13212
13213 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13214         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13215         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13216         return ((uint32_t)ret_conv);
13217 }
13218 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13219         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13220         uint32_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13221         return ret_val;
13222 }
13223
13224 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13225         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13226         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13227         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13228         return ((uint32_t)ret_conv);
13229 }
13230
13231 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13232         LDKSignature a_ref;
13233         CHECK(a->arr_len == 64);
13234         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13235         LDKCVec_SignatureZ b_constr;
13236         b_constr.datalen = b->arr_len;
13237         if (b_constr.datalen > 0)
13238                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13239         else
13240                 b_constr.data = NULL;
13241         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13242         for (size_t m = 0; m < b_constr.datalen; m++) {
13243                 int8_tArray b_conv_12 = b_vals[m];
13244                 LDKSignature b_conv_12_ref;
13245                 CHECK(b_conv_12->arr_len == 64);
13246                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13247                 b_constr.data[m] = b_conv_12_ref;
13248         }
13249         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13250         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13251         return ((uint32_t)ret_conv);
13252 }
13253
13254 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13255         if ((_res & 1) != 0) return;
13256         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13257         CHECK_ACCESS(_res_ptr);
13258         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13259         FREE((void*)_res);
13260         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13261 }
13262
13263 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13264         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13265         CHECK_ACCESS(o_ptr);
13266         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13267         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13268         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13269         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13270         return (uint32_t)ret_conv;
13271 }
13272
13273 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13274         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13275         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13276         return (uint32_t)ret_conv;
13277 }
13278
13279 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13280         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13281         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13282         return ret_val;
13283 }
13284
13285 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13286         if ((_res & 1) != 0) return;
13287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13288         CHECK_ACCESS(_res_ptr);
13289         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13290         FREE((void*)_res);
13291         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13292 }
13293
13294 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13295         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13296         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13297         return (uint32_t)ret_conv;
13298 }
13299 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13300         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13301         uint32_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13302         return ret_val;
13303 }
13304
13305 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13306         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13307         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13308         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13309         return (uint32_t)ret_conv;
13310 }
13311
13312 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13313         LDKSignature o_ref;
13314         CHECK(o->arr_len == 64);
13315         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13316         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13317         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13318         return (uint32_t)ret_conv;
13319 }
13320
13321 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13322         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13323         *ret_conv = CResult_SignatureNoneZ_err();
13324         return (uint32_t)ret_conv;
13325 }
13326
13327 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13328         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13329         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13330         return ret_val;
13331 }
13332
13333 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13334         if ((_res & 1) != 0) return;
13335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13336         CHECK_ACCESS(_res_ptr);
13337         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13338         FREE((void*)_res);
13339         CResult_SignatureNoneZ_free(_res_conv);
13340 }
13341
13342 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13343         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13344         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13345         return (uint32_t)ret_conv;
13346 }
13347 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13348         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13349         uint32_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13350         return ret_val;
13351 }
13352
13353 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13354         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13355         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13356         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13357         return (uint32_t)ret_conv;
13358 }
13359
13360 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13361         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13362         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13363         return ((uint32_t)ret_conv);
13364 }
13365 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13366         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13367         uint32_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13368         return ret_val;
13369 }
13370
13371 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13372         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13373         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13374         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13375         return ((uint32_t)ret_conv);
13376 }
13377
13378 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13379         LDKSignature a_ref;
13380         CHECK(a->arr_len == 64);
13381         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13382         LDKSignature b_ref;
13383         CHECK(b->arr_len == 64);
13384         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13385         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13386         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13387         return ((uint32_t)ret_conv);
13388 }
13389
13390 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13391         if ((_res & 1) != 0) return;
13392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13393         CHECK_ACCESS(_res_ptr);
13394         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13395         FREE((void*)_res);
13396         C2Tuple_SignatureSignatureZ_free(_res_conv);
13397 }
13398
13399 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13400         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13401         CHECK_ACCESS(o_ptr);
13402         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13403         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13404         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13405         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13406         return (uint32_t)ret_conv;
13407 }
13408
13409 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13410         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13411         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13412         return (uint32_t)ret_conv;
13413 }
13414
13415 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13416         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13417         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13418         return ret_val;
13419 }
13420
13421 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13422         if ((_res & 1) != 0) return;
13423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13424         CHECK_ACCESS(_res_ptr);
13425         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13426         FREE((void*)_res);
13427         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13428 }
13429
13430 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13431         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13432         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13433         return (uint32_t)ret_conv;
13434 }
13435 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13436         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13437         uint32_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13438         return ret_val;
13439 }
13440
13441 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13442         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13443         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13444         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13445         return (uint32_t)ret_conv;
13446 }
13447
13448 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13449         LDKSecretKey o_ref;
13450         CHECK(o->arr_len == 32);
13451         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13452         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13453         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13454         return (uint32_t)ret_conv;
13455 }
13456
13457 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13458         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13459         *ret_conv = CResult_SecretKeyNoneZ_err();
13460         return (uint32_t)ret_conv;
13461 }
13462
13463 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13464         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13465         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
13466         return ret_val;
13467 }
13468
13469 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13470         if ((_res & 1) != 0) return;
13471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13472         CHECK_ACCESS(_res_ptr);
13473         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13474         FREE((void*)_res);
13475         CResult_SecretKeyNoneZ_free(_res_conv);
13476 }
13477
13478 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13479         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13480         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13481         return (uint32_t)ret_conv;
13482 }
13483 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13484         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13485         uint32_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13486         return ret_val;
13487 }
13488
13489 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13490         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13491         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13492         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13493         return (uint32_t)ret_conv;
13494 }
13495
13496 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13497         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13498         CHECK_ACCESS(o_ptr);
13499         LDKSign o_conv = *(LDKSign*)(o_ptr);
13500         if (o_conv.free == LDKSign_JCalls_free) {
13501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13502                 LDKSign_JCalls_cloned(&o_conv);
13503         }
13504         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13505         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13506         return (uint32_t)ret_conv;
13507 }
13508
13509 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13510         LDKDecodeError e_conv;
13511         e_conv.inner = (void*)(e & (~1));
13512         e_conv.is_owned = (e & 1) || (e == 0);
13513         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13514         e_conv = DecodeError_clone(&e_conv);
13515         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13516         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13517         return (uint32_t)ret_conv;
13518 }
13519
13520 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13521         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13522         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13523         return ret_val;
13524 }
13525
13526 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13527         if ((_res & 1) != 0) return;
13528         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13529         CHECK_ACCESS(_res_ptr);
13530         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13531         FREE((void*)_res);
13532         CResult_SignDecodeErrorZ_free(_res_conv);
13533 }
13534
13535 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13536         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13537         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13538         return (uint32_t)ret_conv;
13539 }
13540 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13541         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13542         uint32_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13543         return ret_val;
13544 }
13545
13546 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13547         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13548         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13549         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13550         return (uint32_t)ret_conv;
13551 }
13552
13553 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13554         LDKCVec_u5Z _res_constr;
13555         _res_constr.datalen = _res->arr_len;
13556         if (_res_constr.datalen > 0)
13557                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13558         else
13559                 _res_constr.data = NULL;
13560         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13561         for (size_t h = 0; h < _res_constr.datalen; h++) {
13562                 int8_t _res_conv_7 = _res_vals[h];
13563                 
13564                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13565         }
13566         CVec_u5Z_free(_res_constr);
13567 }
13568
13569 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13570         LDKRecoverableSignature o_ref;
13571         CHECK(o->arr_len == 68);
13572         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13573         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13574         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13575         return (uint32_t)ret_conv;
13576 }
13577
13578 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13579         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13580         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13581         return (uint32_t)ret_conv;
13582 }
13583
13584 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13585         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13586         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13587         return ret_val;
13588 }
13589
13590 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13591         if ((_res & 1) != 0) return;
13592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13593         CHECK_ACCESS(_res_ptr);
13594         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13595         FREE((void*)_res);
13596         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13597 }
13598
13599 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13600         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13601         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13602         return (uint32_t)ret_conv;
13603 }
13604 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13605         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13606         uint32_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13607         return ret_val;
13608 }
13609
13610 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13611         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13612         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13613         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13614         return (uint32_t)ret_conv;
13615 }
13616
13617 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13618         LDKCVec_u8Z _res_ref;
13619         _res_ref.datalen = _res->arr_len;
13620         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13621         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13622         CVec_u8Z_free(_res_ref);
13623 }
13624
13625 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13626         LDKCVec_CVec_u8ZZ _res_constr;
13627         _res_constr.datalen = _res->arr_len;
13628         if (_res_constr.datalen > 0)
13629                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13630         else
13631                 _res_constr.data = NULL;
13632         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13633         for (size_t m = 0; m < _res_constr.datalen; m++) {
13634                 int8_tArray _res_conv_12 = _res_vals[m];
13635                 LDKCVec_u8Z _res_conv_12_ref;
13636                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13637                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13638                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13639                 _res_constr.data[m] = _res_conv_12_ref;
13640         }
13641         CVec_CVec_u8ZZ_free(_res_constr);
13642 }
13643
13644 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13645         LDKCVec_CVec_u8ZZ o_constr;
13646         o_constr.datalen = o->arr_len;
13647         if (o_constr.datalen > 0)
13648                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13649         else
13650                 o_constr.data = NULL;
13651         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13652         for (size_t m = 0; m < o_constr.datalen; m++) {
13653                 int8_tArray o_conv_12 = o_vals[m];
13654                 LDKCVec_u8Z o_conv_12_ref;
13655                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13656                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13657                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13658                 o_constr.data[m] = o_conv_12_ref;
13659         }
13660         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13661         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13662         return (uint32_t)ret_conv;
13663 }
13664
13665 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13666         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13667         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13668         return (uint32_t)ret_conv;
13669 }
13670
13671 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13672         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13673         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13674         return ret_val;
13675 }
13676
13677 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13678         if ((_res & 1) != 0) return;
13679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13680         CHECK_ACCESS(_res_ptr);
13681         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13682         FREE((void*)_res);
13683         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13684 }
13685
13686 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13687         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13688         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13689         return (uint32_t)ret_conv;
13690 }
13691 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13692         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13693         uint32_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13694         return ret_val;
13695 }
13696
13697 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13698         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13699         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13700         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13701         return (uint32_t)ret_conv;
13702 }
13703
13704 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13705         LDKInMemorySigner o_conv;
13706         o_conv.inner = (void*)(o & (~1));
13707         o_conv.is_owned = (o & 1) || (o == 0);
13708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13709         o_conv = InMemorySigner_clone(&o_conv);
13710         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13711         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13712         return (uint32_t)ret_conv;
13713 }
13714
13715 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13716         LDKDecodeError e_conv;
13717         e_conv.inner = (void*)(e & (~1));
13718         e_conv.is_owned = (e & 1) || (e == 0);
13719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13720         e_conv = DecodeError_clone(&e_conv);
13721         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13722         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13723         return (uint32_t)ret_conv;
13724 }
13725
13726 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13727         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13728         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13729         return ret_val;
13730 }
13731
13732 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13733         if ((_res & 1) != 0) return;
13734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13735         CHECK_ACCESS(_res_ptr);
13736         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13737         FREE((void*)_res);
13738         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13739 }
13740
13741 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13742         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13743         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13744         return (uint32_t)ret_conv;
13745 }
13746 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13747         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13748         uint32_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13749         return ret_val;
13750 }
13751
13752 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13753         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13754         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13755         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13756         return (uint32_t)ret_conv;
13757 }
13758
13759 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13760         LDKCVec_TxOutZ _res_constr;
13761         _res_constr.datalen = _res->arr_len;
13762         if (_res_constr.datalen > 0)
13763                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13764         else
13765                 _res_constr.data = NULL;
13766         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13767         for (size_t h = 0; h < _res_constr.datalen; h++) {
13768                 uint32_t _res_conv_7 = _res_vals[h];
13769                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13770                 CHECK_ACCESS(_res_conv_7_ptr);
13771                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13772                 FREE((void*)_res_conv_7);
13773                 _res_constr.data[h] = _res_conv_7_conv;
13774         }
13775         CVec_TxOutZ_free(_res_constr);
13776 }
13777
13778 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13779         LDKTransaction o_ref;
13780         o_ref.datalen = o->arr_len;
13781         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13782         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13783         o_ref.data_is_owned = true;
13784         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13785         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13786         return (uint32_t)ret_conv;
13787 }
13788
13789 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13790         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13791         *ret_conv = CResult_TransactionNoneZ_err();
13792         return (uint32_t)ret_conv;
13793 }
13794
13795 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13796         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13797         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13798         return ret_val;
13799 }
13800
13801 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13802         if ((_res & 1) != 0) return;
13803         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13804         CHECK_ACCESS(_res_ptr);
13805         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13806         FREE((void*)_res);
13807         CResult_TransactionNoneZ_free(_res_conv);
13808 }
13809
13810 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13811         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13812         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13813         return (uint32_t)ret_conv;
13814 }
13815 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13816         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13817         uint32_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13818         return ret_val;
13819 }
13820
13821 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13822         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13823         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13824         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13825         return (uint32_t)ret_conv;
13826 }
13827
13828 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13829         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13830         *ret_copy = COption_u16Z_some(o);
13831         uint32_t ret_ref = (uintptr_t)ret_copy;
13832         return ret_ref;
13833 }
13834
13835 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13836         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13837         *ret_copy = COption_u16Z_none();
13838         uint32_t ret_ref = (uintptr_t)ret_copy;
13839         return ret_ref;
13840 }
13841
13842 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13843         if ((_res & 1) != 0) return;
13844         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13845         CHECK_ACCESS(_res_ptr);
13846         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13847         FREE((void*)_res);
13848         COption_u16Z_free(_res_conv);
13849 }
13850
13851 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13852         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13853         *ret_copy = COption_u16Z_clone(arg);
13854 uint32_t ret_ref = (uintptr_t)ret_copy;
13855         return ret_ref;
13856 }
13857 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13858         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13859         uint32_t ret_val = COption_u16Z_clone_ptr(arg_conv);
13860         return ret_val;
13861 }
13862
13863 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13864         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13865         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13866         *ret_copy = COption_u16Z_clone(orig_conv);
13867         uint32_t ret_ref = (uintptr_t)ret_copy;
13868         return ret_ref;
13869 }
13870
13871 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13872         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13873         *ret_conv = CResult_NoneAPIErrorZ_ok();
13874         return (uint32_t)ret_conv;
13875 }
13876
13877 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13878         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13879         CHECK_ACCESS(e_ptr);
13880         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13881         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13882         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13883         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13884         return (uint32_t)ret_conv;
13885 }
13886
13887 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13888         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13889         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
13890         return ret_val;
13891 }
13892
13893 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13894         if ((_res & 1) != 0) return;
13895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13896         CHECK_ACCESS(_res_ptr);
13897         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13898         FREE((void*)_res);
13899         CResult_NoneAPIErrorZ_free(_res_conv);
13900 }
13901
13902 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13903         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13904         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13905         return (uint32_t)ret_conv;
13906 }
13907 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13908         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13909         uint32_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13910         return ret_val;
13911 }
13912
13913 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13914         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13915         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13916         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13917         return (uint32_t)ret_conv;
13918 }
13919
13920 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13921         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13922         _res_constr.datalen = _res->arr_len;
13923         if (_res_constr.datalen > 0)
13924                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13925         else
13926                 _res_constr.data = NULL;
13927         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13928         for (size_t w = 0; w < _res_constr.datalen; w++) {
13929                 uint32_t _res_conv_22 = _res_vals[w];
13930                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13931                 CHECK_ACCESS(_res_conv_22_ptr);
13932                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13933                 FREE((void*)_res_conv_22);
13934                 _res_constr.data[w] = _res_conv_22_conv;
13935         }
13936         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13937 }
13938
13939 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13940         LDKCVec_APIErrorZ _res_constr;
13941         _res_constr.datalen = _res->arr_len;
13942         if (_res_constr.datalen > 0)
13943                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13944         else
13945                 _res_constr.data = NULL;
13946         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13947         for (size_t k = 0; k < _res_constr.datalen; k++) {
13948                 uint32_t _res_conv_10 = _res_vals[k];
13949                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
13950                 CHECK_ACCESS(_res_conv_10_ptr);
13951                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13952                 FREE((void*)_res_conv_10);
13953                 _res_constr.data[k] = _res_conv_10_conv;
13954         }
13955         CVec_APIErrorZ_free(_res_constr);
13956 }
13957
13958 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
13959         LDKThirtyTwoBytes o_ref;
13960         CHECK(o->arr_len == 32);
13961         memcpy(o_ref.data, o->elems, 32); FREE(o);
13962         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13963         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13964         return (uint32_t)ret_conv;
13965 }
13966
13967 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
13968         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13969         CHECK_ACCESS(e_ptr);
13970         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13971         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13972         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13973         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13974         return (uint32_t)ret_conv;
13975 }
13976
13977 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
13978         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
13979         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
13980         return ret_val;
13981 }
13982
13983 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
13984         if ((_res & 1) != 0) return;
13985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13986         CHECK_ACCESS(_res_ptr);
13987         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13988         FREE((void*)_res);
13989         CResult__u832APIErrorZ_free(_res_conv);
13990 }
13991
13992 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
13993         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13994         *ret_conv = CResult__u832APIErrorZ_clone(arg);
13995         return (uint32_t)ret_conv;
13996 }
13997 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
13998         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
13999         uint32_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14000         return ret_val;
14001 }
14002
14003 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
14004         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14005         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14006         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14007         return (uint32_t)ret_conv;
14008 }
14009
14010 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
14011         LDKThirtyTwoBytes o_ref;
14012         CHECK(o->arr_len == 32);
14013         memcpy(o_ref.data, o->elems, 32); FREE(o);
14014         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14015         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14016         return (uint32_t)ret_conv;
14017 }
14018
14019 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
14020         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14021         CHECK_ACCESS(e_ptr);
14022         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14023         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14024         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14025         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14026         return (uint32_t)ret_conv;
14027 }
14028
14029 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
14030         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14031         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14032         return ret_val;
14033 }
14034
14035 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
14036         if ((_res & 1) != 0) return;
14037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14038         CHECK_ACCESS(_res_ptr);
14039         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14040         FREE((void*)_res);
14041         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14042 }
14043
14044 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14045         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14046         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14047         return (uint32_t)ret_conv;
14048 }
14049 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14050         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14051         uint32_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14052         return ret_val;
14053 }
14054
14055 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
14056         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14057         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14058         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14059         return (uint32_t)ret_conv;
14060 }
14061
14062 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
14063         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14064         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14065         return (uint32_t)ret_conv;
14066 }
14067
14068 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
14069         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14070         CHECK_ACCESS(e_ptr);
14071         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14072         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14073         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14074         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14075         return (uint32_t)ret_conv;
14076 }
14077
14078 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
14079         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14080         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14081         return ret_val;
14082 }
14083
14084 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
14085         if ((_res & 1) != 0) return;
14086         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14087         CHECK_ACCESS(_res_ptr);
14088         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14089         FREE((void*)_res);
14090         CResult_NonePaymentSendFailureZ_free(_res_conv);
14091 }
14092
14093 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14094         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14095         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14096         return (uint32_t)ret_conv;
14097 }
14098 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
14099         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14100         uint32_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14101         return ret_val;
14102 }
14103
14104 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
14105         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14106         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14107         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14108         return (uint32_t)ret_conv;
14109 }
14110
14111 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14112         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14113         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14114         return ((uint32_t)ret_conv);
14115 }
14116 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
14117         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14118         uint32_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14119         return ret_val;
14120 }
14121
14122 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
14123         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14124         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14125         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14126         return ((uint32_t)ret_conv);
14127 }
14128
14129 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
14130         LDKThirtyTwoBytes a_ref;
14131         CHECK(a->arr_len == 32);
14132         memcpy(a_ref.data, a->elems, 32); FREE(a);
14133         LDKThirtyTwoBytes b_ref;
14134         CHECK(b->arr_len == 32);
14135         memcpy(b_ref.data, b->elems, 32); FREE(b);
14136         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14137         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14138         return ((uint32_t)ret_conv);
14139 }
14140
14141 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
14142         if ((_res & 1) != 0) return;
14143         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14144         CHECK_ACCESS(_res_ptr);
14145         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14146         FREE((void*)_res);
14147         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14148 }
14149
14150 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
14151         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14152         CHECK_ACCESS(o_ptr);
14153         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14154         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
14155         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14156         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14157         return (uint32_t)ret_conv;
14158 }
14159
14160 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
14161         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14162         CHECK_ACCESS(e_ptr);
14163         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14164         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14165         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14166         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14167         return (uint32_t)ret_conv;
14168 }
14169
14170 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
14171         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14172         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14173         return ret_val;
14174 }
14175
14176 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
14177         if ((_res & 1) != 0) return;
14178         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14179         CHECK_ACCESS(_res_ptr);
14180         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14181         FREE((void*)_res);
14182         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14183 }
14184
14185 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14186         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14187         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14188         return (uint32_t)ret_conv;
14189 }
14190 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14191         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14192         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14193         return ret_val;
14194 }
14195
14196 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14197         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14198         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14199         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14200         return (uint32_t)ret_conv;
14201 }
14202
14203 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14204         LDKCVec_NetAddressZ _res_constr;
14205         _res_constr.datalen = _res->arr_len;
14206         if (_res_constr.datalen > 0)
14207                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14208         else
14209                 _res_constr.data = NULL;
14210         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14211         for (size_t m = 0; m < _res_constr.datalen; m++) {
14212                 uint32_t _res_conv_12 = _res_vals[m];
14213                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14214                 CHECK_ACCESS(_res_conv_12_ptr);
14215                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14216                 FREE((void*)_res_conv_12);
14217                 _res_constr.data[m] = _res_conv_12_conv;
14218         }
14219         CVec_NetAddressZ_free(_res_constr);
14220 }
14221
14222 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14223         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14224         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14225         return ((uint32_t)ret_conv);
14226 }
14227 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14228         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14229         uint32_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14230         return ret_val;
14231 }
14232
14233 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14234         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14235         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14236         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14237         return ((uint32_t)ret_conv);
14238 }
14239
14240 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14241         LDKThirtyTwoBytes a_ref;
14242         CHECK(a->arr_len == 32);
14243         memcpy(a_ref.data, a->elems, 32); FREE(a);
14244         LDKThirtyTwoBytes b_ref;
14245         CHECK(b->arr_len == 32);
14246         memcpy(b_ref.data, b->elems, 32); FREE(b);
14247         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14248         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14249         return ((uint32_t)ret_conv);
14250 }
14251
14252 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14253         if ((_res & 1) != 0) return;
14254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14255         CHECK_ACCESS(_res_ptr);
14256         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14257         FREE((void*)_res);
14258         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14259 }
14260
14261 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14262         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14263         CHECK_ACCESS(o_ptr);
14264         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14265         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14266         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14267         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14268         return (uint32_t)ret_conv;
14269 }
14270
14271 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14272         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14273         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14274         return (uint32_t)ret_conv;
14275 }
14276
14277 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14278         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14279         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14280         return ret_val;
14281 }
14282
14283 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14284         if ((_res & 1) != 0) return;
14285         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14286         CHECK_ACCESS(_res_ptr);
14287         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14288         FREE((void*)_res);
14289         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14290 }
14291
14292 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14293         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14294         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14295         return (uint32_t)ret_conv;
14296 }
14297 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14298         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14299         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14300         return ret_val;
14301 }
14302
14303 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14304         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14305         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14306         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14307         return (uint32_t)ret_conv;
14308 }
14309
14310 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14311         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14312         CHECK_ACCESS(o_ptr);
14313         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14314         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14315         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14316         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14317         return (uint32_t)ret_conv;
14318 }
14319
14320 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14321         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14322         CHECK_ACCESS(e_ptr);
14323         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14324         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14325         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14326         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14327         return (uint32_t)ret_conv;
14328 }
14329
14330 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14331         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14332         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14333         return ret_val;
14334 }
14335
14336 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14337         if ((_res & 1) != 0) return;
14338         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14339         CHECK_ACCESS(_res_ptr);
14340         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14341         FREE((void*)_res);
14342         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14343 }
14344
14345 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14346         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14347         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14348         return (uint32_t)ret_conv;
14349 }
14350 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14351         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14352         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14353         return ret_val;
14354 }
14355
14356 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14357         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14358         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14359         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14360         return (uint32_t)ret_conv;
14361 }
14362
14363 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14364         LDKThirtyTwoBytes o_ref;
14365         CHECK(o->arr_len == 32);
14366         memcpy(o_ref.data, o->elems, 32); FREE(o);
14367         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14368         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14369         return (uint32_t)ret_conv;
14370 }
14371
14372 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14373         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14374         *ret_conv = CResult_PaymentSecretNoneZ_err();
14375         return (uint32_t)ret_conv;
14376 }
14377
14378 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14379         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14380         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14381         return ret_val;
14382 }
14383
14384 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14385         if ((_res & 1) != 0) return;
14386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14387         CHECK_ACCESS(_res_ptr);
14388         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14389         FREE((void*)_res);
14390         CResult_PaymentSecretNoneZ_free(_res_conv);
14391 }
14392
14393 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14394         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14395         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14396         return (uint32_t)ret_conv;
14397 }
14398 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14399         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14400         uint32_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14401         return ret_val;
14402 }
14403
14404 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14405         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14406         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14407         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14408         return (uint32_t)ret_conv;
14409 }
14410
14411 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14412         LDKThirtyTwoBytes o_ref;
14413         CHECK(o->arr_len == 32);
14414         memcpy(o_ref.data, o->elems, 32); FREE(o);
14415         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14416         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14417         return (uint32_t)ret_conv;
14418 }
14419
14420 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14421         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14422         CHECK_ACCESS(e_ptr);
14423         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14424         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14425         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14426         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14427         return (uint32_t)ret_conv;
14428 }
14429
14430 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14431         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14432         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14433         return ret_val;
14434 }
14435
14436 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14437         if ((_res & 1) != 0) return;
14438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14439         CHECK_ACCESS(_res_ptr);
14440         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14441         FREE((void*)_res);
14442         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14443 }
14444
14445 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14446         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14447         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14448         return (uint32_t)ret_conv;
14449 }
14450 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14451         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14452         uint32_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14453         return ret_val;
14454 }
14455
14456 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14457         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14458         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14459         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14460         return (uint32_t)ret_conv;
14461 }
14462
14463 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14464         LDKThirtyTwoBytes o_ref;
14465         CHECK(o->arr_len == 32);
14466         memcpy(o_ref.data, o->elems, 32); FREE(o);
14467         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14468         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14469         return (uint32_t)ret_conv;
14470 }
14471
14472 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14473         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14474         CHECK_ACCESS(e_ptr);
14475         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14476         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14477         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14478         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14479         return (uint32_t)ret_conv;
14480 }
14481
14482 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14483         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14484         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14485         return ret_val;
14486 }
14487
14488 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14489         if ((_res & 1) != 0) return;
14490         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14491         CHECK_ACCESS(_res_ptr);
14492         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14493         FREE((void*)_res);
14494         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14495 }
14496
14497 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14498         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14499         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14500         return (uint32_t)ret_conv;
14501 }
14502 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14503         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14504         uint32_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14505         return ret_val;
14506 }
14507
14508 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14509         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14510         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14511         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14512         return (uint32_t)ret_conv;
14513 }
14514
14515 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14516         LDKCounterpartyForwardingInfo o_conv;
14517         o_conv.inner = (void*)(o & (~1));
14518         o_conv.is_owned = (o & 1) || (o == 0);
14519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14520         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14521         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14522         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14523         return (uint32_t)ret_conv;
14524 }
14525
14526 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14527         LDKDecodeError e_conv;
14528         e_conv.inner = (void*)(e & (~1));
14529         e_conv.is_owned = (e & 1) || (e == 0);
14530         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14531         e_conv = DecodeError_clone(&e_conv);
14532         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14533         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14534         return (uint32_t)ret_conv;
14535 }
14536
14537 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14538         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14539         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14540         return ret_val;
14541 }
14542
14543 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14544         if ((_res & 1) != 0) return;
14545         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14546         CHECK_ACCESS(_res_ptr);
14547         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14548         FREE((void*)_res);
14549         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14550 }
14551
14552 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14553         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14554         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14555         return (uint32_t)ret_conv;
14556 }
14557 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14558         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14559         uint32_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14560         return ret_val;
14561 }
14562
14563 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14564         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14565         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14566         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14567         return (uint32_t)ret_conv;
14568 }
14569
14570 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14571         LDKChannelCounterparty o_conv;
14572         o_conv.inner = (void*)(o & (~1));
14573         o_conv.is_owned = (o & 1) || (o == 0);
14574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14575         o_conv = ChannelCounterparty_clone(&o_conv);
14576         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14577         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14578         return (uint32_t)ret_conv;
14579 }
14580
14581 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14582         LDKDecodeError e_conv;
14583         e_conv.inner = (void*)(e & (~1));
14584         e_conv.is_owned = (e & 1) || (e == 0);
14585         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14586         e_conv = DecodeError_clone(&e_conv);
14587         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14588         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14589         return (uint32_t)ret_conv;
14590 }
14591
14592 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14593         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14594         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14595         return ret_val;
14596 }
14597
14598 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14599         if ((_res & 1) != 0) return;
14600         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14601         CHECK_ACCESS(_res_ptr);
14602         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14603         FREE((void*)_res);
14604         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14605 }
14606
14607 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14608         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14609         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14610         return (uint32_t)ret_conv;
14611 }
14612 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14613         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14614         uint32_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14615         return ret_val;
14616 }
14617
14618 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14619         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14620         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14621         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14622         return (uint32_t)ret_conv;
14623 }
14624
14625 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14626         LDKChannelDetails o_conv;
14627         o_conv.inner = (void*)(o & (~1));
14628         o_conv.is_owned = (o & 1) || (o == 0);
14629         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14630         o_conv = ChannelDetails_clone(&o_conv);
14631         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14632         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14633         return (uint32_t)ret_conv;
14634 }
14635
14636 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14637         LDKDecodeError e_conv;
14638         e_conv.inner = (void*)(e & (~1));
14639         e_conv.is_owned = (e & 1) || (e == 0);
14640         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14641         e_conv = DecodeError_clone(&e_conv);
14642         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14643         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14644         return (uint32_t)ret_conv;
14645 }
14646
14647 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14648         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14649         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14650         return ret_val;
14651 }
14652
14653 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14654         if ((_res & 1) != 0) return;
14655         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14656         CHECK_ACCESS(_res_ptr);
14657         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14658         FREE((void*)_res);
14659         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14660 }
14661
14662 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14663         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14664         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14665         return (uint32_t)ret_conv;
14666 }
14667 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14668         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14669         uint32_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14670         return ret_val;
14671 }
14672
14673 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14674         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14675         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14676         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14677         return (uint32_t)ret_conv;
14678 }
14679
14680 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14681         LDKPhantomRouteHints o_conv;
14682         o_conv.inner = (void*)(o & (~1));
14683         o_conv.is_owned = (o & 1) || (o == 0);
14684         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14685         o_conv = PhantomRouteHints_clone(&o_conv);
14686         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14687         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14688         return (uint32_t)ret_conv;
14689 }
14690
14691 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14692         LDKDecodeError e_conv;
14693         e_conv.inner = (void*)(e & (~1));
14694         e_conv.is_owned = (e & 1) || (e == 0);
14695         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14696         e_conv = DecodeError_clone(&e_conv);
14697         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14698         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14699         return (uint32_t)ret_conv;
14700 }
14701
14702 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14703         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14704         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14705         return ret_val;
14706 }
14707
14708 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14709         if ((_res & 1) != 0) return;
14710         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14711         CHECK_ACCESS(_res_ptr);
14712         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14713         FREE((void*)_res);
14714         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14715 }
14716
14717 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14718         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14719         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14720         return (uint32_t)ret_conv;
14721 }
14722 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14723         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14724         uint32_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14725         return ret_val;
14726 }
14727
14728 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14729         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14730         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14731         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14732         return (uint32_t)ret_conv;
14733 }
14734
14735 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14736         LDKCVec_ChannelMonitorZ _res_constr;
14737         _res_constr.datalen = _res->arr_len;
14738         if (_res_constr.datalen > 0)
14739                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14740         else
14741                 _res_constr.data = NULL;
14742         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14743         for (size_t q = 0; q < _res_constr.datalen; q++) {
14744                 uint32_t _res_conv_16 = _res_vals[q];
14745                 LDKChannelMonitor _res_conv_16_conv;
14746                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14747                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14748                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14749                 _res_constr.data[q] = _res_conv_16_conv;
14750         }
14751         CVec_ChannelMonitorZ_free(_res_constr);
14752 }
14753
14754 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14755         LDKThirtyTwoBytes a_ref;
14756         CHECK(a->arr_len == 32);
14757         memcpy(a_ref.data, a->elems, 32); FREE(a);
14758         LDKChannelManager b_conv;
14759         b_conv.inner = (void*)(b & (~1));
14760         b_conv.is_owned = (b & 1) || (b == 0);
14761         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14762         // WARNING: we need a move here but no clone is available for LDKChannelManager
14763         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14764         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14765         return ((uint32_t)ret_conv);
14766 }
14767
14768 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14769         if ((_res & 1) != 0) return;
14770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14771         CHECK_ACCESS(_res_ptr);
14772         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14773         FREE((void*)_res);
14774         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14775 }
14776
14777 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14778         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14779         CHECK_ACCESS(o_ptr);
14780         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14781         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14782         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14783         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14784         return (uint32_t)ret_conv;
14785 }
14786
14787 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14788         LDKDecodeError e_conv;
14789         e_conv.inner = (void*)(e & (~1));
14790         e_conv.is_owned = (e & 1) || (e == 0);
14791         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14792         e_conv = DecodeError_clone(&e_conv);
14793         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14794         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14795         return (uint32_t)ret_conv;
14796 }
14797
14798 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14799         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14800         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14801         return ret_val;
14802 }
14803
14804 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14805         if ((_res & 1) != 0) return;
14806         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14807         CHECK_ACCESS(_res_ptr);
14808         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14809         FREE((void*)_res);
14810         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14811 }
14812
14813 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14814         LDKChannelConfig o_conv;
14815         o_conv.inner = (void*)(o & (~1));
14816         o_conv.is_owned = (o & 1) || (o == 0);
14817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14818         o_conv = ChannelConfig_clone(&o_conv);
14819         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14820         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14821         return (uint32_t)ret_conv;
14822 }
14823
14824 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14825         LDKDecodeError e_conv;
14826         e_conv.inner = (void*)(e & (~1));
14827         e_conv.is_owned = (e & 1) || (e == 0);
14828         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14829         e_conv = DecodeError_clone(&e_conv);
14830         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14831         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14832         return (uint32_t)ret_conv;
14833 }
14834
14835 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14836         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14837         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14838         return ret_val;
14839 }
14840
14841 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14842         if ((_res & 1) != 0) return;
14843         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14844         CHECK_ACCESS(_res_ptr);
14845         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14846         FREE((void*)_res);
14847         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14848 }
14849
14850 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14851         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14852         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14853         return (uint32_t)ret_conv;
14854 }
14855 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14856         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14857         uint32_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14858         return ret_val;
14859 }
14860
14861 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14862         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14863         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14864         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14865         return (uint32_t)ret_conv;
14866 }
14867
14868 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14869         LDKOutPoint o_conv;
14870         o_conv.inner = (void*)(o & (~1));
14871         o_conv.is_owned = (o & 1) || (o == 0);
14872         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14873         o_conv = OutPoint_clone(&o_conv);
14874         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14875         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14876         return (uint32_t)ret_conv;
14877 }
14878
14879 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14880         LDKDecodeError e_conv;
14881         e_conv.inner = (void*)(e & (~1));
14882         e_conv.is_owned = (e & 1) || (e == 0);
14883         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14884         e_conv = DecodeError_clone(&e_conv);
14885         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14886         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14887         return (uint32_t)ret_conv;
14888 }
14889
14890 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14891         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14892         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14893         return ret_val;
14894 }
14895
14896 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14897         if ((_res & 1) != 0) return;
14898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14899         CHECK_ACCESS(_res_ptr);
14900         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14901         FREE((void*)_res);
14902         CResult_OutPointDecodeErrorZ_free(_res_conv);
14903 }
14904
14905 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14906         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14907         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14908         return (uint32_t)ret_conv;
14909 }
14910 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14911         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14912         uint32_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14913         return ret_val;
14914 }
14915
14916 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14917         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14918         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14919         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14920         return (uint32_t)ret_conv;
14921 }
14922
14923 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14924         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14925         CHECK_ACCESS(o_ptr);
14926         LDKType o_conv = *(LDKType*)(o_ptr);
14927         if (o_conv.free == LDKType_JCalls_free) {
14928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14929                 LDKType_JCalls_cloned(&o_conv);
14930         }
14931         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14932         *ret_copy = COption_TypeZ_some(o_conv);
14933         uint32_t ret_ref = (uintptr_t)ret_copy;
14934         return ret_ref;
14935 }
14936
14937 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14938         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14939         *ret_copy = COption_TypeZ_none();
14940         uint32_t ret_ref = (uintptr_t)ret_copy;
14941         return ret_ref;
14942 }
14943
14944 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
14945         if ((_res & 1) != 0) return;
14946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14947         CHECK_ACCESS(_res_ptr);
14948         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14949         FREE((void*)_res);
14950         COption_TypeZ_free(_res_conv);
14951 }
14952
14953 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14954         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14955         *ret_copy = COption_TypeZ_clone(arg);
14956 uint32_t ret_ref = (uintptr_t)ret_copy;
14957         return ret_ref;
14958 }
14959 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
14960         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14961         uint32_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14962         return ret_val;
14963 }
14964
14965 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
14966         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14967         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14968         *ret_copy = COption_TypeZ_clone(orig_conv);
14969         uint32_t ret_ref = (uintptr_t)ret_copy;
14970         return ret_ref;
14971 }
14972
14973 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
14974         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14975         CHECK_ACCESS(o_ptr);
14976         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14977         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
14978         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14979         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14980         return (uint32_t)ret_conv;
14981 }
14982
14983 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
14984         LDKDecodeError e_conv;
14985         e_conv.inner = (void*)(e & (~1));
14986         e_conv.is_owned = (e & 1) || (e == 0);
14987         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14988         e_conv = DecodeError_clone(&e_conv);
14989         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14990         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14991         return (uint32_t)ret_conv;
14992 }
14993
14994 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
14995         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14996         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14997         return ret_val;
14998 }
14999
15000 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
15001         if ((_res & 1) != 0) return;
15002         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15003         CHECK_ACCESS(_res_ptr);
15004         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
15005         FREE((void*)_res);
15006         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
15007 }
15008
15009 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
15010         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15011         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
15012         return (uint32_t)ret_conv;
15013 }
15014 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
15015         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
15016         uint32_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
15017         return ret_val;
15018 }
15019
15020 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
15021         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
15022         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15023         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
15024         return (uint32_t)ret_conv;
15025 }
15026
15027 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
15028         LDKThirtyTwoBytes o_ref;
15029         CHECK(o->arr_len == 32);
15030         memcpy(o_ref.data, o->elems, 32); FREE(o);
15031         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15032         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
15033         return (uint32_t)ret_conv;
15034 }
15035
15036 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
15037         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15038         CHECK_ACCESS(e_ptr);
15039         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
15040         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
15041         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15042         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15043         return (uint32_t)ret_conv;
15044 }
15045
15046 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
15047         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15048         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15049         return ret_val;
15050 }
15051
15052 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
15053         if ((_res & 1) != 0) return;
15054         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15055         CHECK_ACCESS(_res_ptr);
15056         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15057         FREE((void*)_res);
15058         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15059 }
15060
15061 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15062         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15063         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15064         return (uint32_t)ret_conv;
15065 }
15066 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
15067         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15068         uint32_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15069         return ret_val;
15070 }
15071
15072 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
15073         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15074         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15075         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15076         return (uint32_t)ret_conv;
15077 }
15078
15079 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
15080         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
15081         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15082         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
15083         return (uint32_t)ret_conv;
15084 }
15085
15086 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
15087         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15088         CHECK_ACCESS(e_ptr);
15089         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15090         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15091         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15092         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
15093         return (uint32_t)ret_conv;
15094 }
15095
15096 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
15097         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
15098         jboolean ret_val = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
15099         return ret_val;
15100 }
15101
15102 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
15103         if ((_res & 1) != 0) return;
15104         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15105         CHECK_ACCESS(_res_ptr);
15106         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
15107         FREE((void*)_res);
15108         CResult_SiPrefixParseErrorZ_free(_res_conv);
15109 }
15110
15111 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
15112         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15113         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
15114         return (uint32_t)ret_conv;
15115 }
15116 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
15117         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
15118         uint32_t ret_val = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
15119         return ret_val;
15120 }
15121
15122 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
15123         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
15124         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15125         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
15126         return (uint32_t)ret_conv;
15127 }
15128
15129 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
15130         LDKInvoice o_conv;
15131         o_conv.inner = (void*)(o & (~1));
15132         o_conv.is_owned = (o & 1) || (o == 0);
15133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15134         o_conv = Invoice_clone(&o_conv);
15135         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15136         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
15137         return (uint32_t)ret_conv;
15138 }
15139
15140 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
15141         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15142         CHECK_ACCESS(e_ptr);
15143         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
15144         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
15145         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15146         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
15147         return (uint32_t)ret_conv;
15148 }
15149
15150 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
15151         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
15152         jboolean ret_val = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
15153         return ret_val;
15154 }
15155
15156 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
15157         if ((_res & 1) != 0) return;
15158         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15159         CHECK_ACCESS(_res_ptr);
15160         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
15161         FREE((void*)_res);
15162         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
15163 }
15164
15165 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
15166         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15167         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
15168         return (uint32_t)ret_conv;
15169 }
15170 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
15171         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
15172         uint32_t ret_val = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
15173         return ret_val;
15174 }
15175
15176 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
15177         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
15178         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15179         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
15180         return (uint32_t)ret_conv;
15181 }
15182
15183 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
15184         LDKSignedRawInvoice o_conv;
15185         o_conv.inner = (void*)(o & (~1));
15186         o_conv.is_owned = (o & 1) || (o == 0);
15187         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15188         o_conv = SignedRawInvoice_clone(&o_conv);
15189         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15190         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
15191         return (uint32_t)ret_conv;
15192 }
15193
15194 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
15195         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15196         CHECK_ACCESS(e_ptr);
15197         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15198         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15199         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15200         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
15201         return (uint32_t)ret_conv;
15202 }
15203
15204 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
15205         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
15206         jboolean ret_val = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
15207         return ret_val;
15208 }
15209
15210 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
15211         if ((_res & 1) != 0) return;
15212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15213         CHECK_ACCESS(_res_ptr);
15214         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
15215         FREE((void*)_res);
15216         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
15217 }
15218
15219 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
15220         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15221         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
15222         return (uint32_t)ret_conv;
15223 }
15224 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
15225         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
15226         uint32_t ret_val = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
15227         return ret_val;
15228 }
15229
15230 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
15231         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
15232         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15233         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
15234         return (uint32_t)ret_conv;
15235 }
15236
15237 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15238         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15239         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15240         return ((uint32_t)ret_conv);
15241 }
15242 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15243         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15244         uint32_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15245         return ret_val;
15246 }
15247
15248 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15249         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15250         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15251         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15252         return ((uint32_t)ret_conv);
15253 }
15254
15255 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15256         LDKRawInvoice a_conv;
15257         a_conv.inner = (void*)(a & (~1));
15258         a_conv.is_owned = (a & 1) || (a == 0);
15259         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15260         a_conv = RawInvoice_clone(&a_conv);
15261         LDKThirtyTwoBytes b_ref;
15262         CHECK(b->arr_len == 32);
15263         memcpy(b_ref.data, b->elems, 32); FREE(b);
15264         LDKInvoiceSignature c_conv;
15265         c_conv.inner = (void*)(c & (~1));
15266         c_conv.is_owned = (c & 1) || (c == 0);
15267         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15268         c_conv = InvoiceSignature_clone(&c_conv);
15269         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15270         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15271         return ((uint32_t)ret_conv);
15272 }
15273
15274 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15275         if ((_res & 1) != 0) return;
15276         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15277         CHECK_ACCESS(_res_ptr);
15278         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15279         FREE((void*)_res);
15280         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15281 }
15282
15283 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15284         LDKPayeePubKey o_conv;
15285         o_conv.inner = (void*)(o & (~1));
15286         o_conv.is_owned = (o & 1) || (o == 0);
15287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15288         o_conv = PayeePubKey_clone(&o_conv);
15289         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15290         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15291         return (uint32_t)ret_conv;
15292 }
15293
15294 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15295         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15296         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15297         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15298         return (uint32_t)ret_conv;
15299 }
15300
15301 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15302         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15303         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15304         return ret_val;
15305 }
15306
15307 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15308         if ((_res & 1) != 0) return;
15309         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15310         CHECK_ACCESS(_res_ptr);
15311         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15312         FREE((void*)_res);
15313         CResult_PayeePubKeyErrorZ_free(_res_conv);
15314 }
15315
15316 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15317         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15318         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15319         return (uint32_t)ret_conv;
15320 }
15321 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15322         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15323         uint32_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15324         return ret_val;
15325 }
15326
15327 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15328         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15329         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15330         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15331         return (uint32_t)ret_conv;
15332 }
15333
15334 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15335         LDKCVec_PrivateRouteZ _res_constr;
15336         _res_constr.datalen = _res->arr_len;
15337         if (_res_constr.datalen > 0)
15338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15339         else
15340                 _res_constr.data = NULL;
15341         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15342         for (size_t o = 0; o < _res_constr.datalen; o++) {
15343                 uint32_t _res_conv_14 = _res_vals[o];
15344                 LDKPrivateRoute _res_conv_14_conv;
15345                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15346                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15347                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15348                 _res_constr.data[o] = _res_conv_14_conv;
15349         }
15350         CVec_PrivateRouteZ_free(_res_constr);
15351 }
15352
15353 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15354         LDKPositiveTimestamp o_conv;
15355         o_conv.inner = (void*)(o & (~1));
15356         o_conv.is_owned = (o & 1) || (o == 0);
15357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15358         o_conv = PositiveTimestamp_clone(&o_conv);
15359         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15360         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15361         return (uint32_t)ret_conv;
15362 }
15363
15364 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15365         LDKCreationError e_conv = LDKCreationError_from_js(e);
15366         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15367         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15368         return (uint32_t)ret_conv;
15369 }
15370
15371 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15372         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15373         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15374         return ret_val;
15375 }
15376
15377 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15378         if ((_res & 1) != 0) return;
15379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15380         CHECK_ACCESS(_res_ptr);
15381         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15382         FREE((void*)_res);
15383         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15384 }
15385
15386 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15387         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15388         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15389         return (uint32_t)ret_conv;
15390 }
15391 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15392         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15393         uint32_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15394         return ret_val;
15395 }
15396
15397 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15398         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15399         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15400         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15401         return (uint32_t)ret_conv;
15402 }
15403
15404 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15405         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15406         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15407         return (uint32_t)ret_conv;
15408 }
15409
15410 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15411         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15412         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15413         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15414         return (uint32_t)ret_conv;
15415 }
15416
15417 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15418         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15419         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15420         return ret_val;
15421 }
15422
15423 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15424         if ((_res & 1) != 0) return;
15425         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15426         CHECK_ACCESS(_res_ptr);
15427         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15428         FREE((void*)_res);
15429         CResult_NoneSemanticErrorZ_free(_res_conv);
15430 }
15431
15432 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15433         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15434         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15435         return (uint32_t)ret_conv;
15436 }
15437 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15438         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15439         uint32_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15440         return ret_val;
15441 }
15442
15443 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15444         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15445         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15446         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15447         return (uint32_t)ret_conv;
15448 }
15449
15450 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15451         LDKInvoice o_conv;
15452         o_conv.inner = (void*)(o & (~1));
15453         o_conv.is_owned = (o & 1) || (o == 0);
15454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15455         o_conv = Invoice_clone(&o_conv);
15456         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15457         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15458         return (uint32_t)ret_conv;
15459 }
15460
15461 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15462         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15463         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15464         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15465         return (uint32_t)ret_conv;
15466 }
15467
15468 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15469         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15470         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15471         return ret_val;
15472 }
15473
15474 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15475         if ((_res & 1) != 0) return;
15476         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15477         CHECK_ACCESS(_res_ptr);
15478         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15479         FREE((void*)_res);
15480         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15481 }
15482
15483 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15484         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15485         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15486         return (uint32_t)ret_conv;
15487 }
15488 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15489         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15490         uint32_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15491         return ret_val;
15492 }
15493
15494 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15495         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15496         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15497         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15498         return (uint32_t)ret_conv;
15499 }
15500
15501 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15502         LDKDescription o_conv;
15503         o_conv.inner = (void*)(o & (~1));
15504         o_conv.is_owned = (o & 1) || (o == 0);
15505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15506         o_conv = Description_clone(&o_conv);
15507         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15508         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15509         return (uint32_t)ret_conv;
15510 }
15511
15512 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15513         LDKCreationError e_conv = LDKCreationError_from_js(e);
15514         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15515         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15516         return (uint32_t)ret_conv;
15517 }
15518
15519 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15520         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15521         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15522         return ret_val;
15523 }
15524
15525 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15526         if ((_res & 1) != 0) return;
15527         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15528         CHECK_ACCESS(_res_ptr);
15529         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15530         FREE((void*)_res);
15531         CResult_DescriptionCreationErrorZ_free(_res_conv);
15532 }
15533
15534 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15535         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15536         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15537         return (uint32_t)ret_conv;
15538 }
15539 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15540         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15541         uint32_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15542         return ret_val;
15543 }
15544
15545 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15546         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15547         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15548         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15549         return (uint32_t)ret_conv;
15550 }
15551
15552 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15553         LDKPrivateRoute o_conv;
15554         o_conv.inner = (void*)(o & (~1));
15555         o_conv.is_owned = (o & 1) || (o == 0);
15556         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15557         o_conv = PrivateRoute_clone(&o_conv);
15558         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15559         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15560         return (uint32_t)ret_conv;
15561 }
15562
15563 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15564         LDKCreationError e_conv = LDKCreationError_from_js(e);
15565         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15566         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15567         return (uint32_t)ret_conv;
15568 }
15569
15570 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15571         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15572         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15573         return ret_val;
15574 }
15575
15576 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15577         if ((_res & 1) != 0) return;
15578         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15579         CHECK_ACCESS(_res_ptr);
15580         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15581         FREE((void*)_res);
15582         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15583 }
15584
15585 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15586         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15587         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15588         return (uint32_t)ret_conv;
15589 }
15590 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15591         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15592         uint32_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15593         return ret_val;
15594 }
15595
15596 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15597         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15598         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15599         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15600         return (uint32_t)ret_conv;
15601 }
15602
15603 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15604         LDKStr o_conv = str_ref_to_owned_c(o);
15605         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15606         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15607         return (uint32_t)ret_conv;
15608 }
15609
15610 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15611         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15612         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15613         *ret_conv = CResult_StringErrorZ_err(e_conv);
15614         return (uint32_t)ret_conv;
15615 }
15616
15617 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15618         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15619         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15620         return ret_val;
15621 }
15622
15623 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15624         if ((_res & 1) != 0) return;
15625         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15626         CHECK_ACCESS(_res_ptr);
15627         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15628         FREE((void*)_res);
15629         CResult_StringErrorZ_free(_res_conv);
15630 }
15631
15632 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15633         LDKChannelMonitorUpdate o_conv;
15634         o_conv.inner = (void*)(o & (~1));
15635         o_conv.is_owned = (o & 1) || (o == 0);
15636         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15637         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15638         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15639         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15640         return (uint32_t)ret_conv;
15641 }
15642
15643 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15644         LDKDecodeError e_conv;
15645         e_conv.inner = (void*)(e & (~1));
15646         e_conv.is_owned = (e & 1) || (e == 0);
15647         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15648         e_conv = DecodeError_clone(&e_conv);
15649         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15650         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15651         return (uint32_t)ret_conv;
15652 }
15653
15654 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15655         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15656         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15657         return ret_val;
15658 }
15659
15660 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15661         if ((_res & 1) != 0) return;
15662         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15663         CHECK_ACCESS(_res_ptr);
15664         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15665         FREE((void*)_res);
15666         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15667 }
15668
15669 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15670         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15671         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15672         return (uint32_t)ret_conv;
15673 }
15674 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15675         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15676         uint32_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15677         return ret_val;
15678 }
15679
15680 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15681         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15682         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15683         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15684         return (uint32_t)ret_conv;
15685 }
15686
15687 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15688         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15689         CHECK_ACCESS(o_ptr);
15690         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15691         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15692         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15693         *ret_copy = COption_MonitorEventZ_some(o_conv);
15694         uint32_t ret_ref = (uintptr_t)ret_copy;
15695         return ret_ref;
15696 }
15697
15698 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15699         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15700         *ret_copy = COption_MonitorEventZ_none();
15701         uint32_t ret_ref = (uintptr_t)ret_copy;
15702         return ret_ref;
15703 }
15704
15705 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15706         if ((_res & 1) != 0) return;
15707         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15708         CHECK_ACCESS(_res_ptr);
15709         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15710         FREE((void*)_res);
15711         COption_MonitorEventZ_free(_res_conv);
15712 }
15713
15714 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15715         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15716         *ret_copy = COption_MonitorEventZ_clone(arg);
15717 uint32_t ret_ref = (uintptr_t)ret_copy;
15718         return ret_ref;
15719 }
15720 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15721         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15722         uint32_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15723         return ret_val;
15724 }
15725
15726 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15727         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15728         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15729         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15730         uint32_t ret_ref = (uintptr_t)ret_copy;
15731         return ret_ref;
15732 }
15733
15734 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15735         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15736         CHECK_ACCESS(o_ptr);
15737         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15738         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15739         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15740         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15741         return (uint32_t)ret_conv;
15742 }
15743
15744 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15745         LDKDecodeError e_conv;
15746         e_conv.inner = (void*)(e & (~1));
15747         e_conv.is_owned = (e & 1) || (e == 0);
15748         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15749         e_conv = DecodeError_clone(&e_conv);
15750         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15751         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15752         return (uint32_t)ret_conv;
15753 }
15754
15755 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15756         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15757         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15758         return ret_val;
15759 }
15760
15761 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15762         if ((_res & 1) != 0) return;
15763         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15764         CHECK_ACCESS(_res_ptr);
15765         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15766         FREE((void*)_res);
15767         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15768 }
15769
15770 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15771         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15772         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15773         return (uint32_t)ret_conv;
15774 }
15775 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15776         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15777         uint32_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15778         return ret_val;
15779 }
15780
15781 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15782         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15783         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15784         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15785         return (uint32_t)ret_conv;
15786 }
15787
15788 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15789         LDKHTLCUpdate o_conv;
15790         o_conv.inner = (void*)(o & (~1));
15791         o_conv.is_owned = (o & 1) || (o == 0);
15792         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15793         o_conv = HTLCUpdate_clone(&o_conv);
15794         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15795         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15796         return (uint32_t)ret_conv;
15797 }
15798
15799 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15800         LDKDecodeError e_conv;
15801         e_conv.inner = (void*)(e & (~1));
15802         e_conv.is_owned = (e & 1) || (e == 0);
15803         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15804         e_conv = DecodeError_clone(&e_conv);
15805         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15806         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15807         return (uint32_t)ret_conv;
15808 }
15809
15810 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15811         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15812         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15813         return ret_val;
15814 }
15815
15816 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15817         if ((_res & 1) != 0) return;
15818         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15819         CHECK_ACCESS(_res_ptr);
15820         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15821         FREE((void*)_res);
15822         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15823 }
15824
15825 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15826         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15827         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15828         return (uint32_t)ret_conv;
15829 }
15830 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15831         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15832         uint32_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15833         return ret_val;
15834 }
15835
15836 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15837         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15838         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15839         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15840         return (uint32_t)ret_conv;
15841 }
15842
15843 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15844         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15845         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15846         return ((uint32_t)ret_conv);
15847 }
15848 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15849         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15850         uint32_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15851         return ret_val;
15852 }
15853
15854 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15855         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15856         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15857         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15858         return ((uint32_t)ret_conv);
15859 }
15860
15861 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15862         LDKOutPoint a_conv;
15863         a_conv.inner = (void*)(a & (~1));
15864         a_conv.is_owned = (a & 1) || (a == 0);
15865         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15866         a_conv = OutPoint_clone(&a_conv);
15867         LDKCVec_u8Z b_ref;
15868         b_ref.datalen = b->arr_len;
15869         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15870         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15871         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15872         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15873         return ((uint32_t)ret_conv);
15874 }
15875
15876 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15877         if ((_res & 1) != 0) return;
15878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15879         CHECK_ACCESS(_res_ptr);
15880         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15881         FREE((void*)_res);
15882         C2Tuple_OutPointScriptZ_free(_res_conv);
15883 }
15884
15885 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15886         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15887         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15888         return ((uint32_t)ret_conv);
15889 }
15890 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15891         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15892         uint32_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15893         return ret_val;
15894 }
15895
15896 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15897         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15898         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15899         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15900         return ((uint32_t)ret_conv);
15901 }
15902
15903 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15904         LDKCVec_u8Z b_ref;
15905         b_ref.datalen = b->arr_len;
15906         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15907         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15908         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15909         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15910         return ((uint32_t)ret_conv);
15911 }
15912
15913 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15914         if ((_res & 1) != 0) return;
15915         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15916         CHECK_ACCESS(_res_ptr);
15917         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15918         FREE((void*)_res);
15919         C2Tuple_u32ScriptZ_free(_res_conv);
15920 }
15921
15922 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15923         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15924         _res_constr.datalen = _res->arr_len;
15925         if (_res_constr.datalen > 0)
15926                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15927         else
15928                 _res_constr.data = NULL;
15929         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15930         for (size_t v = 0; v < _res_constr.datalen; v++) {
15931                 uint32_t _res_conv_21 = _res_vals[v];
15932                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15933                 CHECK_ACCESS(_res_conv_21_ptr);
15934                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15935                 FREE((void*)_res_conv_21);
15936                 _res_constr.data[v] = _res_conv_21_conv;
15937         }
15938         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15939 }
15940
15941 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15942         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15943         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15944         return ((uint32_t)ret_conv);
15945 }
15946 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
15947         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15948         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15949         return ret_val;
15950 }
15951
15952 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
15953         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15954         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15955         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15956         return ((uint32_t)ret_conv);
15957 }
15958
15959 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
15960         LDKThirtyTwoBytes a_ref;
15961         CHECK(a->arr_len == 32);
15962         memcpy(a_ref.data, a->elems, 32); FREE(a);
15963         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15964         b_constr.datalen = b->arr_len;
15965         if (b_constr.datalen > 0)
15966                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15967         else
15968                 b_constr.data = NULL;
15969         uint32_t* b_vals = b->elems /* XXX b leaks */;
15970         for (size_t v = 0; v < b_constr.datalen; v++) {
15971                 uint32_t b_conv_21 = b_vals[v];
15972                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
15973                 CHECK_ACCESS(b_conv_21_ptr);
15974                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15975                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
15976                 b_constr.data[v] = b_conv_21_conv;
15977         }
15978         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15979         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15980         return ((uint32_t)ret_conv);
15981 }
15982
15983 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
15984         if ((_res & 1) != 0) return;
15985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15986         CHECK_ACCESS(_res_ptr);
15987         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15988         FREE((void*)_res);
15989         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15990 }
15991
15992 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
15993         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15994         _res_constr.datalen = _res->arr_len;
15995         if (_res_constr.datalen > 0)
15996                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15997         else
15998                 _res_constr.data = NULL;
15999         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16000         for (size_t o = 0; o < _res_constr.datalen; o++) {
16001                 uint32_t _res_conv_40 = _res_vals[o];
16002                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
16003                 CHECK_ACCESS(_res_conv_40_ptr);
16004                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
16005                 FREE((void*)_res_conv_40);
16006                 _res_constr.data[o] = _res_conv_40_conv;
16007         }
16008         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
16009 }
16010
16011 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
16012         LDKCVec_EventZ _res_constr;
16013         _res_constr.datalen = _res->arr_len;
16014         if (_res_constr.datalen > 0)
16015                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
16016         else
16017                 _res_constr.data = NULL;
16018         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16019         for (size_t h = 0; h < _res_constr.datalen; h++) {
16020                 uint32_t _res_conv_7 = _res_vals[h];
16021                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
16022                 CHECK_ACCESS(_res_conv_7_ptr);
16023                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
16024                 FREE((void*)_res_conv_7);
16025                 _res_constr.data[h] = _res_conv_7_conv;
16026         }
16027         CVec_EventZ_free(_res_constr);
16028 }
16029
16030 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
16031         LDKCVec_TransactionZ _res_constr;
16032         _res_constr.datalen = _res->arr_len;
16033         if (_res_constr.datalen > 0)
16034                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
16035         else
16036                 _res_constr.data = NULL;
16037         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16038         for (size_t m = 0; m < _res_constr.datalen; m++) {
16039                 int8_tArray _res_conv_12 = _res_vals[m];
16040                 LDKTransaction _res_conv_12_ref;
16041                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
16042                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
16043                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
16044                 _res_conv_12_ref.data_is_owned = true;
16045                 _res_constr.data[m] = _res_conv_12_ref;
16046         }
16047         CVec_TransactionZ_free(_res_constr);
16048 }
16049
16050 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
16051         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16052         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
16053         return ((uint32_t)ret_conv);
16054 }
16055 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
16056         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16057         uint32_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16058         return ret_val;
16059 }
16060
16061 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
16062         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16063         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16064         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16065         return ((uint32_t)ret_conv);
16066 }
16067
16068 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
16069         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16070         CHECK_ACCESS(b_ptr);
16071         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16072         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
16073         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16074         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16075         return ((uint32_t)ret_conv);
16076 }
16077
16078 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
16079         if ((_res & 1) != 0) return;
16080         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16081         CHECK_ACCESS(_res_ptr);
16082         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16083         FREE((void*)_res);
16084         C2Tuple_u32TxOutZ_free(_res_conv);
16085 }
16086
16087 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
16088         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16089         _res_constr.datalen = _res->arr_len;
16090         if (_res_constr.datalen > 0)
16091                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16092         else
16093                 _res_constr.data = NULL;
16094         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16095         for (size_t u = 0; u < _res_constr.datalen; u++) {
16096                 uint32_t _res_conv_20 = _res_vals[u];
16097                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
16098                 CHECK_ACCESS(_res_conv_20_ptr);
16099                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16100                 FREE((void*)_res_conv_20);
16101                 _res_constr.data[u] = _res_conv_20_conv;
16102         }
16103         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16104 }
16105
16106 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16107         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16108         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16109         return ((uint32_t)ret_conv);
16110 }
16111 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
16112         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16113         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16114         return ret_val;
16115 }
16116
16117 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
16118         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16119         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16120         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16121         return ((uint32_t)ret_conv);
16122 }
16123
16124 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
16125         LDKThirtyTwoBytes a_ref;
16126         CHECK(a->arr_len == 32);
16127         memcpy(a_ref.data, a->elems, 32); FREE(a);
16128         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16129         b_constr.datalen = b->arr_len;
16130         if (b_constr.datalen > 0)
16131                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16132         else
16133                 b_constr.data = NULL;
16134         uint32_t* b_vals = b->elems /* XXX b leaks */;
16135         for (size_t u = 0; u < b_constr.datalen; u++) {
16136                 uint32_t b_conv_20 = b_vals[u];
16137                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
16138                 CHECK_ACCESS(b_conv_20_ptr);
16139                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16140                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
16141                 b_constr.data[u] = b_conv_20_conv;
16142         }
16143         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16144         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16145         return ((uint32_t)ret_conv);
16146 }
16147
16148 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
16149         if ((_res & 1) != 0) return;
16150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16151         CHECK_ACCESS(_res_ptr);
16152         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16153         FREE((void*)_res);
16154         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16155 }
16156
16157 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
16158         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16159         _res_constr.datalen = _res->arr_len;
16160         if (_res_constr.datalen > 0)
16161                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16162         else
16163                 _res_constr.data = NULL;
16164         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16165         for (size_t n = 0; n < _res_constr.datalen; n++) {
16166                 uint32_t _res_conv_39 = _res_vals[n];
16167                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
16168                 CHECK_ACCESS(_res_conv_39_ptr);
16169                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16170                 FREE((void*)_res_conv_39);
16171                 _res_constr.data[n] = _res_conv_39_conv;
16172         }
16173         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16174 }
16175
16176 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
16177         LDKCVec_BalanceZ _res_constr;
16178         _res_constr.datalen = _res->arr_len;
16179         if (_res_constr.datalen > 0)
16180                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16181         else
16182                 _res_constr.data = NULL;
16183         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16184         for (size_t j = 0; j < _res_constr.datalen; j++) {
16185                 uint32_t _res_conv_9 = _res_vals[j];
16186                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
16187                 CHECK_ACCESS(_res_conv_9_ptr);
16188                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16189                 FREE((void*)_res_conv_9);
16190                 _res_constr.data[j] = _res_conv_9_conv;
16191         }
16192         CVec_BalanceZ_free(_res_constr);
16193 }
16194
16195 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16196         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16197         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16198         return ((uint32_t)ret_conv);
16199 }
16200 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16201         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16202         uint32_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16203         return ret_val;
16204 }
16205
16206 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16207         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16208         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16209         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16210         return ((uint32_t)ret_conv);
16211 }
16212
16213 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16214         LDKThirtyTwoBytes a_ref;
16215         CHECK(a->arr_len == 32);
16216         memcpy(a_ref.data, a->elems, 32); FREE(a);
16217         LDKChannelMonitor b_conv;
16218         b_conv.inner = (void*)(b & (~1));
16219         b_conv.is_owned = (b & 1) || (b == 0);
16220         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16221         b_conv = ChannelMonitor_clone(&b_conv);
16222         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16223         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16224         return ((uint32_t)ret_conv);
16225 }
16226
16227 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16228         if ((_res & 1) != 0) return;
16229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16230         CHECK_ACCESS(_res_ptr);
16231         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16232         FREE((void*)_res);
16233         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16234 }
16235
16236 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16237         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16238         CHECK_ACCESS(o_ptr);
16239         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16240         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16241         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16242         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16243         return (uint32_t)ret_conv;
16244 }
16245
16246 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16247         LDKDecodeError e_conv;
16248         e_conv.inner = (void*)(e & (~1));
16249         e_conv.is_owned = (e & 1) || (e == 0);
16250         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16251         e_conv = DecodeError_clone(&e_conv);
16252         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16253         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16254         return (uint32_t)ret_conv;
16255 }
16256
16257 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16258         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16259         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16260         return ret_val;
16261 }
16262
16263 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16264         if ((_res & 1) != 0) return;
16265         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16266         CHECK_ACCESS(_res_ptr);
16267         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16268         FREE((void*)_res);
16269         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16270 }
16271
16272 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16273         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16274         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16275         return (uint32_t)ret_conv;
16276 }
16277 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16278         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16279         uint32_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16280         return ret_val;
16281 }
16282
16283 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16284         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16285         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16286         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16287         return (uint32_t)ret_conv;
16288 }
16289
16290 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16291         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16292         *ret_conv = CResult_NoneLightningErrorZ_ok();
16293         return (uint32_t)ret_conv;
16294 }
16295
16296 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16297         LDKLightningError e_conv;
16298         e_conv.inner = (void*)(e & (~1));
16299         e_conv.is_owned = (e & 1) || (e == 0);
16300         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16301         e_conv = LightningError_clone(&e_conv);
16302         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16303         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16304         return (uint32_t)ret_conv;
16305 }
16306
16307 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16308         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16309         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16310         return ret_val;
16311 }
16312
16313 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16314         if ((_res & 1) != 0) return;
16315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16316         CHECK_ACCESS(_res_ptr);
16317         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16318         FREE((void*)_res);
16319         CResult_NoneLightningErrorZ_free(_res_conv);
16320 }
16321
16322 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16323         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16324         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16325         return (uint32_t)ret_conv;
16326 }
16327 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16328         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16329         uint32_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16330         return ret_val;
16331 }
16332
16333 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16334         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16335         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16336         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16337         return (uint32_t)ret_conv;
16338 }
16339
16340 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16341         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16342         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16343         return ((uint32_t)ret_conv);
16344 }
16345 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16346         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16347         uint32_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16348         return ret_val;
16349 }
16350
16351 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16352         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16353         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16354         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16355         return ((uint32_t)ret_conv);
16356 }
16357
16358 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16359         LDKPublicKey a_ref;
16360         CHECK(a->arr_len == 33);
16361         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16362         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16363         CHECK_ACCESS(b_ptr);
16364         LDKType b_conv = *(LDKType*)(b_ptr);
16365         if (b_conv.free == LDKType_JCalls_free) {
16366                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16367                 LDKType_JCalls_cloned(&b_conv);
16368         }
16369         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16370         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16371         return ((uint32_t)ret_conv);
16372 }
16373
16374 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16375         if ((_res & 1) != 0) return;
16376         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16377         CHECK_ACCESS(_res_ptr);
16378         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16379         FREE((void*)_res);
16380         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16381 }
16382
16383 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16384         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16385         _res_constr.datalen = _res->arr_len;
16386         if (_res_constr.datalen > 0)
16387                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16388         else
16389                 _res_constr.data = NULL;
16390         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16391         for (size_t z = 0; z < _res_constr.datalen; z++) {
16392                 uint32_t _res_conv_25 = _res_vals[z];
16393                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16394                 CHECK_ACCESS(_res_conv_25_ptr);
16395                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16396                 FREE((void*)_res_conv_25);
16397                 _res_constr.data[z] = _res_conv_25_conv;
16398         }
16399         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16400 }
16401
16402 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16403         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16404         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16405         return (uint32_t)ret_conv;
16406 }
16407
16408 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16409         LDKLightningError e_conv;
16410         e_conv.inner = (void*)(e & (~1));
16411         e_conv.is_owned = (e & 1) || (e == 0);
16412         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16413         e_conv = LightningError_clone(&e_conv);
16414         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16415         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16416         return (uint32_t)ret_conv;
16417 }
16418
16419 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16420         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16421         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16422         return ret_val;
16423 }
16424
16425 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16426         if ((_res & 1) != 0) return;
16427         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16428         CHECK_ACCESS(_res_ptr);
16429         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16430         FREE((void*)_res);
16431         CResult_boolLightningErrorZ_free(_res_conv);
16432 }
16433
16434 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16435         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16436         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16437         return (uint32_t)ret_conv;
16438 }
16439 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16440         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16441         uint32_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16442         return ret_val;
16443 }
16444
16445 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16446         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16447         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16448         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16449         return (uint32_t)ret_conv;
16450 }
16451
16452 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16453         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16454         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16455         return ((uint32_t)ret_conv);
16456 }
16457 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16458         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16459         uint32_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16460         return ret_val;
16461 }
16462
16463 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16464         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16465         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16466         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16467         return ((uint32_t)ret_conv);
16468 }
16469
16470 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16471         LDKChannelAnnouncement a_conv;
16472         a_conv.inner = (void*)(a & (~1));
16473         a_conv.is_owned = (a & 1) || (a == 0);
16474         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16475         a_conv = ChannelAnnouncement_clone(&a_conv);
16476         LDKChannelUpdate b_conv;
16477         b_conv.inner = (void*)(b & (~1));
16478         b_conv.is_owned = (b & 1) || (b == 0);
16479         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16480         b_conv = ChannelUpdate_clone(&b_conv);
16481         LDKChannelUpdate c_conv;
16482         c_conv.inner = (void*)(c & (~1));
16483         c_conv.is_owned = (c & 1) || (c == 0);
16484         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16485         c_conv = ChannelUpdate_clone(&c_conv);
16486         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16487         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16488         return ((uint32_t)ret_conv);
16489 }
16490
16491 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16492         if ((_res & 1) != 0) return;
16493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16494         CHECK_ACCESS(_res_ptr);
16495         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16496         FREE((void*)_res);
16497         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16498 }
16499
16500 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16501         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16502         _res_constr.datalen = _res->arr_len;
16503         if (_res_constr.datalen > 0)
16504                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16505         else
16506                 _res_constr.data = NULL;
16507         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16508         for (size_t h = 0; h < _res_constr.datalen; h++) {
16509                 uint32_t _res_conv_59 = _res_vals[h];
16510                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16511                 CHECK_ACCESS(_res_conv_59_ptr);
16512                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16513                 FREE((void*)_res_conv_59);
16514                 _res_constr.data[h] = _res_conv_59_conv;
16515         }
16516         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16517 }
16518
16519 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16520         LDKCVec_NodeAnnouncementZ _res_constr;
16521         _res_constr.datalen = _res->arr_len;
16522         if (_res_constr.datalen > 0)
16523                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16524         else
16525                 _res_constr.data = NULL;
16526         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16527         for (size_t s = 0; s < _res_constr.datalen; s++) {
16528                 uint32_t _res_conv_18 = _res_vals[s];
16529                 LDKNodeAnnouncement _res_conv_18_conv;
16530                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16531                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16532                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16533                 _res_constr.data[s] = _res_conv_18_conv;
16534         }
16535         CVec_NodeAnnouncementZ_free(_res_constr);
16536 }
16537
16538 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16539         LDKCVec_PublicKeyZ _res_constr;
16540         _res_constr.datalen = _res->arr_len;
16541         if (_res_constr.datalen > 0)
16542                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16543         else
16544                 _res_constr.data = NULL;
16545         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16546         for (size_t m = 0; m < _res_constr.datalen; m++) {
16547                 int8_tArray _res_conv_12 = _res_vals[m];
16548                 LDKPublicKey _res_conv_12_ref;
16549                 CHECK(_res_conv_12->arr_len == 33);
16550                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16551                 _res_constr.data[m] = _res_conv_12_ref;
16552         }
16553         CVec_PublicKeyZ_free(_res_constr);
16554 }
16555
16556 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
16557         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16558         CHECK_ACCESS(o_ptr);
16559         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
16560         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
16561         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16562         *ret_copy = COption_NetAddressZ_some(o_conv);
16563         uint32_t ret_ref = (uintptr_t)ret_copy;
16564         return ret_ref;
16565 }
16566
16567 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
16568         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16569         *ret_copy = COption_NetAddressZ_none();
16570         uint32_t ret_ref = (uintptr_t)ret_copy;
16571         return ret_ref;
16572 }
16573
16574 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
16575         if ((_res & 1) != 0) return;
16576         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16577         CHECK_ACCESS(_res_ptr);
16578         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
16579         FREE((void*)_res);
16580         COption_NetAddressZ_free(_res_conv);
16581 }
16582
16583 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
16584         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16585         *ret_copy = COption_NetAddressZ_clone(arg);
16586 uint32_t ret_ref = (uintptr_t)ret_copy;
16587         return ret_ref;
16588 }
16589 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
16590         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
16591         uint32_t ret_val = COption_NetAddressZ_clone_ptr(arg_conv);
16592         return ret_val;
16593 }
16594
16595 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
16596         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
16597         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16598         *ret_copy = COption_NetAddressZ_clone(orig_conv);
16599         uint32_t ret_ref = (uintptr_t)ret_copy;
16600         return ret_ref;
16601 }
16602
16603 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16604         LDKCVec_u8Z o_ref;
16605         o_ref.datalen = o->arr_len;
16606         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16607         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16608         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16609         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16610         return (uint32_t)ret_conv;
16611 }
16612
16613 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16614         LDKPeerHandleError e_conv;
16615         e_conv.inner = (void*)(e & (~1));
16616         e_conv.is_owned = (e & 1) || (e == 0);
16617         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16618         e_conv = PeerHandleError_clone(&e_conv);
16619         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16620         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16621         return (uint32_t)ret_conv;
16622 }
16623
16624 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16625         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16626         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16627         return ret_val;
16628 }
16629
16630 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16631         if ((_res & 1) != 0) return;
16632         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16633         CHECK_ACCESS(_res_ptr);
16634         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16635         FREE((void*)_res);
16636         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16637 }
16638
16639 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16640         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16641         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16642         return (uint32_t)ret_conv;
16643 }
16644 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16645         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16646         uint32_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16647         return ret_val;
16648 }
16649
16650 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16651         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16652         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16653         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16654         return (uint32_t)ret_conv;
16655 }
16656
16657 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16658         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16659         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16660         return (uint32_t)ret_conv;
16661 }
16662
16663 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16664         LDKPeerHandleError e_conv;
16665         e_conv.inner = (void*)(e & (~1));
16666         e_conv.is_owned = (e & 1) || (e == 0);
16667         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16668         e_conv = PeerHandleError_clone(&e_conv);
16669         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16670         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16671         return (uint32_t)ret_conv;
16672 }
16673
16674 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16675         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16676         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16677         return ret_val;
16678 }
16679
16680 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16681         if ((_res & 1) != 0) return;
16682         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16683         CHECK_ACCESS(_res_ptr);
16684         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16685         FREE((void*)_res);
16686         CResult_NonePeerHandleErrorZ_free(_res_conv);
16687 }
16688
16689 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16690         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16691         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16692         return (uint32_t)ret_conv;
16693 }
16694 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16695         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16696         uint32_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16697         return ret_val;
16698 }
16699
16700 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16701         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16702         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16703         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16704         return (uint32_t)ret_conv;
16705 }
16706
16707 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16708         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16709         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16710         return (uint32_t)ret_conv;
16711 }
16712
16713 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16714         LDKPeerHandleError e_conv;
16715         e_conv.inner = (void*)(e & (~1));
16716         e_conv.is_owned = (e & 1) || (e == 0);
16717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16718         e_conv = PeerHandleError_clone(&e_conv);
16719         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16720         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16721         return (uint32_t)ret_conv;
16722 }
16723
16724 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16725         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16726         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16727         return ret_val;
16728 }
16729
16730 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16731         if ((_res & 1) != 0) return;
16732         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16733         CHECK_ACCESS(_res_ptr);
16734         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16735         FREE((void*)_res);
16736         CResult_boolPeerHandleErrorZ_free(_res_conv);
16737 }
16738
16739 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16740         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16741         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16742         return (uint32_t)ret_conv;
16743 }
16744 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16745         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16746         uint32_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16747         return ret_val;
16748 }
16749
16750 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16751         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16752         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16753         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16754         return (uint32_t)ret_conv;
16755 }
16756
16757 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16758         LDKNodeId o_conv;
16759         o_conv.inner = (void*)(o & (~1));
16760         o_conv.is_owned = (o & 1) || (o == 0);
16761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16762         o_conv = NodeId_clone(&o_conv);
16763         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16764         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16765         return (uint32_t)ret_conv;
16766 }
16767
16768 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16769         LDKDecodeError e_conv;
16770         e_conv.inner = (void*)(e & (~1));
16771         e_conv.is_owned = (e & 1) || (e == 0);
16772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16773         e_conv = DecodeError_clone(&e_conv);
16774         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16775         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16776         return (uint32_t)ret_conv;
16777 }
16778
16779 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16780         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16781         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16782         return ret_val;
16783 }
16784
16785 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16786         if ((_res & 1) != 0) return;
16787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16788         CHECK_ACCESS(_res_ptr);
16789         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16790         FREE((void*)_res);
16791         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16792 }
16793
16794 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16795         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16796         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16797         return (uint32_t)ret_conv;
16798 }
16799 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16800         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16801         uint32_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16802         return ret_val;
16803 }
16804
16805 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16806         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16807         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16808         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16809         return (uint32_t)ret_conv;
16810 }
16811
16812 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16813         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16814         CHECK_ACCESS(o_ptr);
16815         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16816         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16817         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16818         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16819         return (uint32_t)ret_conv;
16820 }
16821
16822 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16823         LDKDecodeError e_conv;
16824         e_conv.inner = (void*)(e & (~1));
16825         e_conv.is_owned = (e & 1) || (e == 0);
16826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16827         e_conv = DecodeError_clone(&e_conv);
16828         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16829         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16830         return (uint32_t)ret_conv;
16831 }
16832
16833 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16834         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16835         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16836         return ret_val;
16837 }
16838
16839 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16840         if ((_res & 1) != 0) return;
16841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16842         CHECK_ACCESS(_res_ptr);
16843         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16844         FREE((void*)_res);
16845         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16846 }
16847
16848 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16849         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16850         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16851         return (uint32_t)ret_conv;
16852 }
16853 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16854         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16855         uint32_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16856         return ret_val;
16857 }
16858
16859 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16860         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16861         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16862         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16863         return (uint32_t)ret_conv;
16864 }
16865
16866 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16867         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16868         CHECK_ACCESS(o_ptr);
16869         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16870         if (o_conv.free == LDKAccess_JCalls_free) {
16871                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16872                 LDKAccess_JCalls_cloned(&o_conv);
16873         }
16874         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16875         *ret_copy = COption_AccessZ_some(o_conv);
16876         uint32_t ret_ref = (uintptr_t)ret_copy;
16877         return ret_ref;
16878 }
16879
16880 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16881         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16882         *ret_copy = COption_AccessZ_none();
16883         uint32_t ret_ref = (uintptr_t)ret_copy;
16884         return ret_ref;
16885 }
16886
16887 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16888         if ((_res & 1) != 0) return;
16889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16890         CHECK_ACCESS(_res_ptr);
16891         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16892         FREE((void*)_res);
16893         COption_AccessZ_free(_res_conv);
16894 }
16895
16896 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16897         LDKChannelUpdateInfo o_conv;
16898         o_conv.inner = (void*)(o & (~1));
16899         o_conv.is_owned = (o & 1) || (o == 0);
16900         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16901         o_conv = ChannelUpdateInfo_clone(&o_conv);
16902         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16903         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16904         return (uint32_t)ret_conv;
16905 }
16906
16907 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16908         LDKDecodeError e_conv;
16909         e_conv.inner = (void*)(e & (~1));
16910         e_conv.is_owned = (e & 1) || (e == 0);
16911         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16912         e_conv = DecodeError_clone(&e_conv);
16913         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16914         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16915         return (uint32_t)ret_conv;
16916 }
16917
16918 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16919         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16920         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16921         return ret_val;
16922 }
16923
16924 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16925         if ((_res & 1) != 0) return;
16926         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16927         CHECK_ACCESS(_res_ptr);
16928         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16929         FREE((void*)_res);
16930         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16931 }
16932
16933 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16934         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16935         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16936         return (uint32_t)ret_conv;
16937 }
16938 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16939         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16940         uint32_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16941         return ret_val;
16942 }
16943
16944 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
16945         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
16946         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16947         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16948         return (uint32_t)ret_conv;
16949 }
16950
16951 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
16952         LDKChannelInfo o_conv;
16953         o_conv.inner = (void*)(o & (~1));
16954         o_conv.is_owned = (o & 1) || (o == 0);
16955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16956         o_conv = ChannelInfo_clone(&o_conv);
16957         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16958         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16959         return (uint32_t)ret_conv;
16960 }
16961
16962 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
16963         LDKDecodeError e_conv;
16964         e_conv.inner = (void*)(e & (~1));
16965         e_conv.is_owned = (e & 1) || (e == 0);
16966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16967         e_conv = DecodeError_clone(&e_conv);
16968         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16969         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16970         return (uint32_t)ret_conv;
16971 }
16972
16973 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
16974         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16975         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16976         return ret_val;
16977 }
16978
16979 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
16980         if ((_res & 1) != 0) return;
16981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16982         CHECK_ACCESS(_res_ptr);
16983         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16984         FREE((void*)_res);
16985         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16986 }
16987
16988 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16989         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16990         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16991         return (uint32_t)ret_conv;
16992 }
16993 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16994         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16995         uint32_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16996         return ret_val;
16997 }
16998
16999 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
17000         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17001         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17002         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17003         return (uint32_t)ret_conv;
17004 }
17005
17006 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
17007         LDKRoutingFees o_conv;
17008         o_conv.inner = (void*)(o & (~1));
17009         o_conv.is_owned = (o & 1) || (o == 0);
17010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17011         o_conv = RoutingFees_clone(&o_conv);
17012         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17013         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17014         return (uint32_t)ret_conv;
17015 }
17016
17017 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
17018         LDKDecodeError e_conv;
17019         e_conv.inner = (void*)(e & (~1));
17020         e_conv.is_owned = (e & 1) || (e == 0);
17021         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17022         e_conv = DecodeError_clone(&e_conv);
17023         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17024         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17025         return (uint32_t)ret_conv;
17026 }
17027
17028 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
17029         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17030         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17031         return ret_val;
17032 }
17033
17034 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
17035         if ((_res & 1) != 0) return;
17036         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17037         CHECK_ACCESS(_res_ptr);
17038         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17039         FREE((void*)_res);
17040         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17041 }
17042
17043 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17044         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17045         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17046         return (uint32_t)ret_conv;
17047 }
17048 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
17049         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17050         uint32_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17051         return ret_val;
17052 }
17053
17054 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
17055         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17056         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17057         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17058         return (uint32_t)ret_conv;
17059 }
17060
17061 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
17062         LDKNodeAnnouncementInfo o_conv;
17063         o_conv.inner = (void*)(o & (~1));
17064         o_conv.is_owned = (o & 1) || (o == 0);
17065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17066         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17067         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17068         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17069         return (uint32_t)ret_conv;
17070 }
17071
17072 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
17073         LDKDecodeError e_conv;
17074         e_conv.inner = (void*)(e & (~1));
17075         e_conv.is_owned = (e & 1) || (e == 0);
17076         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17077         e_conv = DecodeError_clone(&e_conv);
17078         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17079         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17080         return (uint32_t)ret_conv;
17081 }
17082
17083 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
17084         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17085         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17086         return ret_val;
17087 }
17088
17089 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
17090         if ((_res & 1) != 0) return;
17091         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17092         CHECK_ACCESS(_res_ptr);
17093         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17094         FREE((void*)_res);
17095         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17096 }
17097
17098 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17099         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17100         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17101         return (uint32_t)ret_conv;
17102 }
17103 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17104         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17105         uint32_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17106         return ret_val;
17107 }
17108
17109 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
17110         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17111         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17112         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17113         return (uint32_t)ret_conv;
17114 }
17115
17116 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
17117         LDKCVec_u64Z _res_constr;
17118         _res_constr.datalen = _res->arr_len;
17119         if (_res_constr.datalen > 0)
17120                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17121         else
17122                 _res_constr.data = NULL;
17123         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
17124         for (size_t i = 0; i < _res_constr.datalen; i++) {
17125                 int64_t _res_conv_8 = _res_vals[i];
17126                 _res_constr.data[i] = _res_conv_8;
17127         }
17128         CVec_u64Z_free(_res_constr);
17129 }
17130
17131 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
17132         LDKNodeInfo o_conv;
17133         o_conv.inner = (void*)(o & (~1));
17134         o_conv.is_owned = (o & 1) || (o == 0);
17135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17136         o_conv = NodeInfo_clone(&o_conv);
17137         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17138         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17139         return (uint32_t)ret_conv;
17140 }
17141
17142 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
17143         LDKDecodeError e_conv;
17144         e_conv.inner = (void*)(e & (~1));
17145         e_conv.is_owned = (e & 1) || (e == 0);
17146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17147         e_conv = DecodeError_clone(&e_conv);
17148         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17149         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17150         return (uint32_t)ret_conv;
17151 }
17152
17153 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
17154         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17155         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17156         return ret_val;
17157 }
17158
17159 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
17160         if ((_res & 1) != 0) return;
17161         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17162         CHECK_ACCESS(_res_ptr);
17163         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17164         FREE((void*)_res);
17165         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17166 }
17167
17168 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17169         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17170         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17171         return (uint32_t)ret_conv;
17172 }
17173 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17174         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17175         uint32_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17176         return ret_val;
17177 }
17178
17179 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
17180         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17181         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17182         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17183         return (uint32_t)ret_conv;
17184 }
17185
17186 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
17187         LDKNetworkGraph o_conv;
17188         o_conv.inner = (void*)(o & (~1));
17189         o_conv.is_owned = (o & 1) || (o == 0);
17190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17191         o_conv = NetworkGraph_clone(&o_conv);
17192         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17193         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17194         return (uint32_t)ret_conv;
17195 }
17196
17197 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
17198         LDKDecodeError e_conv;
17199         e_conv.inner = (void*)(e & (~1));
17200         e_conv.is_owned = (e & 1) || (e == 0);
17201         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17202         e_conv = DecodeError_clone(&e_conv);
17203         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17204         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17205         return (uint32_t)ret_conv;
17206 }
17207
17208 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
17209         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17210         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17211         return ret_val;
17212 }
17213
17214 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
17215         if ((_res & 1) != 0) return;
17216         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17217         CHECK_ACCESS(_res_ptr);
17218         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17219         FREE((void*)_res);
17220         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17221 }
17222
17223 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17224         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17225         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17226         return (uint32_t)ret_conv;
17227 }
17228 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
17229         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17230         uint32_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17231         return ret_val;
17232 }
17233
17234 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
17235         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17236         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17237         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17238         return (uint32_t)ret_conv;
17239 }
17240
17241 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
17242         LDKCVec_NetAddressZ o_constr;
17243         o_constr.datalen = o->arr_len;
17244         if (o_constr.datalen > 0)
17245                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17246         else
17247                 o_constr.data = NULL;
17248         uint32_t* o_vals = o->elems /* XXX o leaks */;
17249         for (size_t m = 0; m < o_constr.datalen; m++) {
17250                 uint32_t o_conv_12 = o_vals[m];
17251                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17252                 CHECK_ACCESS(o_conv_12_ptr);
17253                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17254                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17255                 o_constr.data[m] = o_conv_12_conv;
17256         }
17257         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17258         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17259         uint32_t ret_ref = (uintptr_t)ret_copy;
17260         return ret_ref;
17261 }
17262
17263 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17264         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17265         *ret_copy = COption_CVec_NetAddressZZ_none();
17266         uint32_t ret_ref = (uintptr_t)ret_copy;
17267         return ret_ref;
17268 }
17269
17270 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17271         if ((_res & 1) != 0) return;
17272         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17273         CHECK_ACCESS(_res_ptr);
17274         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17275         FREE((void*)_res);
17276         COption_CVec_NetAddressZZ_free(_res_conv);
17277 }
17278
17279 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17280         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17281         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17282 uint32_t ret_ref = (uintptr_t)ret_copy;
17283         return ret_ref;
17284 }
17285 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17286         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17287         uint32_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17288         return ret_val;
17289 }
17290
17291 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17292         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17293         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17294         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17295         uint32_t ret_ref = (uintptr_t)ret_copy;
17296         return ret_ref;
17297 }
17298
17299 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17300         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17301         CHECK_ACCESS(o_ptr);
17302         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17303         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17304         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17305         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17306         return (uint32_t)ret_conv;
17307 }
17308
17309 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17310         LDKDecodeError e_conv;
17311         e_conv.inner = (void*)(e & (~1));
17312         e_conv.is_owned = (e & 1) || (e == 0);
17313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17314         e_conv = DecodeError_clone(&e_conv);
17315         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17316         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17317         return (uint32_t)ret_conv;
17318 }
17319
17320 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17321         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17322         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17323         return ret_val;
17324 }
17325
17326 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17327         if ((_res & 1) != 0) return;
17328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17329         CHECK_ACCESS(_res_ptr);
17330         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17331         FREE((void*)_res);
17332         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17333 }
17334
17335 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17336         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17337         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17338         return (uint32_t)ret_conv;
17339 }
17340 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17341         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17342         uint32_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17343         return ret_val;
17344 }
17345
17346 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17347         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17348         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17349         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17350         return (uint32_t)ret_conv;
17351 }
17352
17353 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17354         LDKCVec_UpdateAddHTLCZ _res_constr;
17355         _res_constr.datalen = _res->arr_len;
17356         if (_res_constr.datalen > 0)
17357                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17358         else
17359                 _res_constr.data = NULL;
17360         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17361         for (size_t p = 0; p < _res_constr.datalen; p++) {
17362                 uint32_t _res_conv_15 = _res_vals[p];
17363                 LDKUpdateAddHTLC _res_conv_15_conv;
17364                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17365                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17366                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17367                 _res_constr.data[p] = _res_conv_15_conv;
17368         }
17369         CVec_UpdateAddHTLCZ_free(_res_constr);
17370 }
17371
17372 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17373         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17374         _res_constr.datalen = _res->arr_len;
17375         if (_res_constr.datalen > 0)
17376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17377         else
17378                 _res_constr.data = NULL;
17379         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17380         for (size_t t = 0; t < _res_constr.datalen; t++) {
17381                 uint32_t _res_conv_19 = _res_vals[t];
17382                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17383                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17384                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17386                 _res_constr.data[t] = _res_conv_19_conv;
17387         }
17388         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17389 }
17390
17391 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17392         LDKCVec_UpdateFailHTLCZ _res_constr;
17393         _res_constr.datalen = _res->arr_len;
17394         if (_res_constr.datalen > 0)
17395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17396         else
17397                 _res_constr.data = NULL;
17398         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17399         for (size_t q = 0; q < _res_constr.datalen; q++) {
17400                 uint32_t _res_conv_16 = _res_vals[q];
17401                 LDKUpdateFailHTLC _res_conv_16_conv;
17402                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17403                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17405                 _res_constr.data[q] = _res_conv_16_conv;
17406         }
17407         CVec_UpdateFailHTLCZ_free(_res_constr);
17408 }
17409
17410 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17411         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17412         _res_constr.datalen = _res->arr_len;
17413         if (_res_constr.datalen > 0)
17414                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17415         else
17416                 _res_constr.data = NULL;
17417         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17418         for (size_t z = 0; z < _res_constr.datalen; z++) {
17419                 uint32_t _res_conv_25 = _res_vals[z];
17420                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17421                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17422                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17423                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17424                 _res_constr.data[z] = _res_conv_25_conv;
17425         }
17426         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17427 }
17428
17429 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17430         LDKAcceptChannel o_conv;
17431         o_conv.inner = (void*)(o & (~1));
17432         o_conv.is_owned = (o & 1) || (o == 0);
17433         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17434         o_conv = AcceptChannel_clone(&o_conv);
17435         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17436         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17437         return (uint32_t)ret_conv;
17438 }
17439
17440 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17441         LDKDecodeError e_conv;
17442         e_conv.inner = (void*)(e & (~1));
17443         e_conv.is_owned = (e & 1) || (e == 0);
17444         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17445         e_conv = DecodeError_clone(&e_conv);
17446         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17447         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17448         return (uint32_t)ret_conv;
17449 }
17450
17451 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17452         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17453         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17454         return ret_val;
17455 }
17456
17457 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17458         if ((_res & 1) != 0) return;
17459         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17460         CHECK_ACCESS(_res_ptr);
17461         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17462         FREE((void*)_res);
17463         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17464 }
17465
17466 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17467         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17468         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17469         return (uint32_t)ret_conv;
17470 }
17471 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17472         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17473         uint32_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17474         return ret_val;
17475 }
17476
17477 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17478         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17479         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17480         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17481         return (uint32_t)ret_conv;
17482 }
17483
17484 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17485         LDKAnnouncementSignatures o_conv;
17486         o_conv.inner = (void*)(o & (~1));
17487         o_conv.is_owned = (o & 1) || (o == 0);
17488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17489         o_conv = AnnouncementSignatures_clone(&o_conv);
17490         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17491         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17492         return (uint32_t)ret_conv;
17493 }
17494
17495 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17496         LDKDecodeError e_conv;
17497         e_conv.inner = (void*)(e & (~1));
17498         e_conv.is_owned = (e & 1) || (e == 0);
17499         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17500         e_conv = DecodeError_clone(&e_conv);
17501         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17502         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17503         return (uint32_t)ret_conv;
17504 }
17505
17506 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17507         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17508         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17509         return ret_val;
17510 }
17511
17512 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17513         if ((_res & 1) != 0) return;
17514         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17515         CHECK_ACCESS(_res_ptr);
17516         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17517         FREE((void*)_res);
17518         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17519 }
17520
17521 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17522         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17523         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17524         return (uint32_t)ret_conv;
17525 }
17526 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17527         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17528         uint32_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17529         return ret_val;
17530 }
17531
17532 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17533         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17534         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17535         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17536         return (uint32_t)ret_conv;
17537 }
17538
17539 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17540         LDKChannelReestablish o_conv;
17541         o_conv.inner = (void*)(o & (~1));
17542         o_conv.is_owned = (o & 1) || (o == 0);
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17544         o_conv = ChannelReestablish_clone(&o_conv);
17545         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17546         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17547         return (uint32_t)ret_conv;
17548 }
17549
17550 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17551         LDKDecodeError e_conv;
17552         e_conv.inner = (void*)(e & (~1));
17553         e_conv.is_owned = (e & 1) || (e == 0);
17554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17555         e_conv = DecodeError_clone(&e_conv);
17556         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17557         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17558         return (uint32_t)ret_conv;
17559 }
17560
17561 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17562         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17563         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17564         return ret_val;
17565 }
17566
17567 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17568         if ((_res & 1) != 0) return;
17569         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17570         CHECK_ACCESS(_res_ptr);
17571         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17572         FREE((void*)_res);
17573         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17574 }
17575
17576 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17577         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17578         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17579         return (uint32_t)ret_conv;
17580 }
17581 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17582         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17583         uint32_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17584         return ret_val;
17585 }
17586
17587 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17588         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17589         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17590         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17591         return (uint32_t)ret_conv;
17592 }
17593
17594 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17595         LDKClosingSigned o_conv;
17596         o_conv.inner = (void*)(o & (~1));
17597         o_conv.is_owned = (o & 1) || (o == 0);
17598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17599         o_conv = ClosingSigned_clone(&o_conv);
17600         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17601         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17602         return (uint32_t)ret_conv;
17603 }
17604
17605 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17606         LDKDecodeError e_conv;
17607         e_conv.inner = (void*)(e & (~1));
17608         e_conv.is_owned = (e & 1) || (e == 0);
17609         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17610         e_conv = DecodeError_clone(&e_conv);
17611         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17612         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17613         return (uint32_t)ret_conv;
17614 }
17615
17616 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17617         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17618         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17619         return ret_val;
17620 }
17621
17622 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17623         if ((_res & 1) != 0) return;
17624         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17625         CHECK_ACCESS(_res_ptr);
17626         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17627         FREE((void*)_res);
17628         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17629 }
17630
17631 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17632         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17633         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17634         return (uint32_t)ret_conv;
17635 }
17636 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17637         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17638         uint32_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17639         return ret_val;
17640 }
17641
17642 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17643         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17644         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17645         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17646         return (uint32_t)ret_conv;
17647 }
17648
17649 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17650         LDKClosingSignedFeeRange o_conv;
17651         o_conv.inner = (void*)(o & (~1));
17652         o_conv.is_owned = (o & 1) || (o == 0);
17653         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17654         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17655         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17656         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17657         return (uint32_t)ret_conv;
17658 }
17659
17660 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17661         LDKDecodeError e_conv;
17662         e_conv.inner = (void*)(e & (~1));
17663         e_conv.is_owned = (e & 1) || (e == 0);
17664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17665         e_conv = DecodeError_clone(&e_conv);
17666         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17667         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17668         return (uint32_t)ret_conv;
17669 }
17670
17671 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17672         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17673         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17674         return ret_val;
17675 }
17676
17677 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17678         if ((_res & 1) != 0) return;
17679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17680         CHECK_ACCESS(_res_ptr);
17681         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17682         FREE((void*)_res);
17683         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17684 }
17685
17686 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17687         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17688         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17689         return (uint32_t)ret_conv;
17690 }
17691 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17692         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17693         uint32_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17694         return ret_val;
17695 }
17696
17697 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17698         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17699         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17700         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17701         return (uint32_t)ret_conv;
17702 }
17703
17704 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17705         LDKCommitmentSigned o_conv;
17706         o_conv.inner = (void*)(o & (~1));
17707         o_conv.is_owned = (o & 1) || (o == 0);
17708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17709         o_conv = CommitmentSigned_clone(&o_conv);
17710         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17711         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17712         return (uint32_t)ret_conv;
17713 }
17714
17715 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17716         LDKDecodeError e_conv;
17717         e_conv.inner = (void*)(e & (~1));
17718         e_conv.is_owned = (e & 1) || (e == 0);
17719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17720         e_conv = DecodeError_clone(&e_conv);
17721         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17722         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17723         return (uint32_t)ret_conv;
17724 }
17725
17726 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17727         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17728         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17729         return ret_val;
17730 }
17731
17732 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17733         if ((_res & 1) != 0) return;
17734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17735         CHECK_ACCESS(_res_ptr);
17736         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17737         FREE((void*)_res);
17738         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17739 }
17740
17741 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17742         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17743         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17744         return (uint32_t)ret_conv;
17745 }
17746 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17747         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17748         uint32_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17749         return ret_val;
17750 }
17751
17752 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17753         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17754         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17755         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17756         return (uint32_t)ret_conv;
17757 }
17758
17759 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17760         LDKFundingCreated o_conv;
17761         o_conv.inner = (void*)(o & (~1));
17762         o_conv.is_owned = (o & 1) || (o == 0);
17763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17764         o_conv = FundingCreated_clone(&o_conv);
17765         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17766         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17767         return (uint32_t)ret_conv;
17768 }
17769
17770 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17771         LDKDecodeError e_conv;
17772         e_conv.inner = (void*)(e & (~1));
17773         e_conv.is_owned = (e & 1) || (e == 0);
17774         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17775         e_conv = DecodeError_clone(&e_conv);
17776         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17777         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17778         return (uint32_t)ret_conv;
17779 }
17780
17781 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17782         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17783         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17784         return ret_val;
17785 }
17786
17787 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17788         if ((_res & 1) != 0) return;
17789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17790         CHECK_ACCESS(_res_ptr);
17791         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17792         FREE((void*)_res);
17793         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17794 }
17795
17796 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17797         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17798         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17799         return (uint32_t)ret_conv;
17800 }
17801 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17802         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17803         uint32_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17804         return ret_val;
17805 }
17806
17807 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17808         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17809         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17810         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17811         return (uint32_t)ret_conv;
17812 }
17813
17814 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17815         LDKFundingSigned o_conv;
17816         o_conv.inner = (void*)(o & (~1));
17817         o_conv.is_owned = (o & 1) || (o == 0);
17818         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17819         o_conv = FundingSigned_clone(&o_conv);
17820         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17821         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17822         return (uint32_t)ret_conv;
17823 }
17824
17825 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17826         LDKDecodeError e_conv;
17827         e_conv.inner = (void*)(e & (~1));
17828         e_conv.is_owned = (e & 1) || (e == 0);
17829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17830         e_conv = DecodeError_clone(&e_conv);
17831         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17832         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17833         return (uint32_t)ret_conv;
17834 }
17835
17836 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17837         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17838         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17839         return ret_val;
17840 }
17841
17842 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17843         if ((_res & 1) != 0) return;
17844         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17845         CHECK_ACCESS(_res_ptr);
17846         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17847         FREE((void*)_res);
17848         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17849 }
17850
17851 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17852         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17853         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17854         return (uint32_t)ret_conv;
17855 }
17856 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17857         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17858         uint32_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17859         return ret_val;
17860 }
17861
17862 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17863         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17864         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17865         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17866         return (uint32_t)ret_conv;
17867 }
17868
17869 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17870         LDKFundingLocked o_conv;
17871         o_conv.inner = (void*)(o & (~1));
17872         o_conv.is_owned = (o & 1) || (o == 0);
17873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17874         o_conv = FundingLocked_clone(&o_conv);
17875         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17876         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17877         return (uint32_t)ret_conv;
17878 }
17879
17880 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17881         LDKDecodeError e_conv;
17882         e_conv.inner = (void*)(e & (~1));
17883         e_conv.is_owned = (e & 1) || (e == 0);
17884         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17885         e_conv = DecodeError_clone(&e_conv);
17886         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17887         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17888         return (uint32_t)ret_conv;
17889 }
17890
17891 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17892         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17893         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17894         return ret_val;
17895 }
17896
17897 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17898         if ((_res & 1) != 0) return;
17899         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17900         CHECK_ACCESS(_res_ptr);
17901         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17902         FREE((void*)_res);
17903         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17904 }
17905
17906 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17907         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17908         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17909         return (uint32_t)ret_conv;
17910 }
17911 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17912         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17913         uint32_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17914         return ret_val;
17915 }
17916
17917 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17918         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17919         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17920         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17921         return (uint32_t)ret_conv;
17922 }
17923
17924 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17925         LDKInit o_conv;
17926         o_conv.inner = (void*)(o & (~1));
17927         o_conv.is_owned = (o & 1) || (o == 0);
17928         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17929         o_conv = Init_clone(&o_conv);
17930         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17931         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17932         return (uint32_t)ret_conv;
17933 }
17934
17935 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17936         LDKDecodeError e_conv;
17937         e_conv.inner = (void*)(e & (~1));
17938         e_conv.is_owned = (e & 1) || (e == 0);
17939         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17940         e_conv = DecodeError_clone(&e_conv);
17941         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17942         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17943         return (uint32_t)ret_conv;
17944 }
17945
17946 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
17947         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17948         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17949         return ret_val;
17950 }
17951
17952 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
17953         if ((_res & 1) != 0) return;
17954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17955         CHECK_ACCESS(_res_ptr);
17956         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17957         FREE((void*)_res);
17958         CResult_InitDecodeErrorZ_free(_res_conv);
17959 }
17960
17961 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17962         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17963         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17964         return (uint32_t)ret_conv;
17965 }
17966 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
17967         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17968         uint32_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17969         return ret_val;
17970 }
17971
17972 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
17973         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17974         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17975         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17976         return (uint32_t)ret_conv;
17977 }
17978
17979 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
17980         LDKOpenChannel o_conv;
17981         o_conv.inner = (void*)(o & (~1));
17982         o_conv.is_owned = (o & 1) || (o == 0);
17983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17984         o_conv = OpenChannel_clone(&o_conv);
17985         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17986         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17987         return (uint32_t)ret_conv;
17988 }
17989
17990 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
17991         LDKDecodeError e_conv;
17992         e_conv.inner = (void*)(e & (~1));
17993         e_conv.is_owned = (e & 1) || (e == 0);
17994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17995         e_conv = DecodeError_clone(&e_conv);
17996         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17997         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17998         return (uint32_t)ret_conv;
17999 }
18000
18001 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18002         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18003         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18004         return ret_val;
18005 }
18006
18007 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18008         if ((_res & 1) != 0) return;
18009         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18010         CHECK_ACCESS(_res_ptr);
18011         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18012         FREE((void*)_res);
18013         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18014 }
18015
18016 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18017         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18018         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18019         return (uint32_t)ret_conv;
18020 }
18021 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18022         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18023         uint32_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18024         return ret_val;
18025 }
18026
18027 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18028         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18029         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18030         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18031         return (uint32_t)ret_conv;
18032 }
18033
18034 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18035         LDKRevokeAndACK o_conv;
18036         o_conv.inner = (void*)(o & (~1));
18037         o_conv.is_owned = (o & 1) || (o == 0);
18038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18039         o_conv = RevokeAndACK_clone(&o_conv);
18040         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18041         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18042         return (uint32_t)ret_conv;
18043 }
18044
18045 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18046         LDKDecodeError e_conv;
18047         e_conv.inner = (void*)(e & (~1));
18048         e_conv.is_owned = (e & 1) || (e == 0);
18049         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18050         e_conv = DecodeError_clone(&e_conv);
18051         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18052         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18053         return (uint32_t)ret_conv;
18054 }
18055
18056 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18057         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18058         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18059         return ret_val;
18060 }
18061
18062 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18063         if ((_res & 1) != 0) return;
18064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18065         CHECK_ACCESS(_res_ptr);
18066         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18067         FREE((void*)_res);
18068         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18069 }
18070
18071 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18072         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18073         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18074         return (uint32_t)ret_conv;
18075 }
18076 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18077         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18078         uint32_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18079         return ret_val;
18080 }
18081
18082 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18083         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18084         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18085         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18086         return (uint32_t)ret_conv;
18087 }
18088
18089 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18090         LDKShutdown o_conv;
18091         o_conv.inner = (void*)(o & (~1));
18092         o_conv.is_owned = (o & 1) || (o == 0);
18093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18094         o_conv = Shutdown_clone(&o_conv);
18095         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18096         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18097         return (uint32_t)ret_conv;
18098 }
18099
18100 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18101         LDKDecodeError e_conv;
18102         e_conv.inner = (void*)(e & (~1));
18103         e_conv.is_owned = (e & 1) || (e == 0);
18104         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18105         e_conv = DecodeError_clone(&e_conv);
18106         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18107         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18108         return (uint32_t)ret_conv;
18109 }
18110
18111 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18112         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18113         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18114         return ret_val;
18115 }
18116
18117 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18118         if ((_res & 1) != 0) return;
18119         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18120         CHECK_ACCESS(_res_ptr);
18121         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18122         FREE((void*)_res);
18123         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18124 }
18125
18126 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18127         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18128         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18129         return (uint32_t)ret_conv;
18130 }
18131 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18132         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18133         uint32_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18134         return ret_val;
18135 }
18136
18137 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18138         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18139         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18140         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18141         return (uint32_t)ret_conv;
18142 }
18143
18144 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18145         LDKUpdateFailHTLC o_conv;
18146         o_conv.inner = (void*)(o & (~1));
18147         o_conv.is_owned = (o & 1) || (o == 0);
18148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18149         o_conv = UpdateFailHTLC_clone(&o_conv);
18150         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18151         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18152         return (uint32_t)ret_conv;
18153 }
18154
18155 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
18156         LDKDecodeError e_conv;
18157         e_conv.inner = (void*)(e & (~1));
18158         e_conv.is_owned = (e & 1) || (e == 0);
18159         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18160         e_conv = DecodeError_clone(&e_conv);
18161         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18162         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18163         return (uint32_t)ret_conv;
18164 }
18165
18166 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18167         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18168         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18169         return ret_val;
18170 }
18171
18172 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
18173         if ((_res & 1) != 0) return;
18174         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18175         CHECK_ACCESS(_res_ptr);
18176         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18177         FREE((void*)_res);
18178         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18179 }
18180
18181 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18182         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18183         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18184         return (uint32_t)ret_conv;
18185 }
18186 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18187         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18188         uint32_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18189         return ret_val;
18190 }
18191
18192 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18193         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18194         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18195         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18196         return (uint32_t)ret_conv;
18197 }
18198
18199 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18200         LDKUpdateFailMalformedHTLC o_conv;
18201         o_conv.inner = (void*)(o & (~1));
18202         o_conv.is_owned = (o & 1) || (o == 0);
18203         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18204         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18205         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18206         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18207         return (uint32_t)ret_conv;
18208 }
18209
18210 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
18211         LDKDecodeError e_conv;
18212         e_conv.inner = (void*)(e & (~1));
18213         e_conv.is_owned = (e & 1) || (e == 0);
18214         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18215         e_conv = DecodeError_clone(&e_conv);
18216         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18217         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18218         return (uint32_t)ret_conv;
18219 }
18220
18221 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18222         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18223         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18224         return ret_val;
18225 }
18226
18227 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
18228         if ((_res & 1) != 0) return;
18229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18230         CHECK_ACCESS(_res_ptr);
18231         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18232         FREE((void*)_res);
18233         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18234 }
18235
18236 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18237         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18238         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18239         return (uint32_t)ret_conv;
18240 }
18241 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18242         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18243         uint32_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18244         return ret_val;
18245 }
18246
18247 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18248         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18249         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18250         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18251         return (uint32_t)ret_conv;
18252 }
18253
18254 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18255         LDKUpdateFee o_conv;
18256         o_conv.inner = (void*)(o & (~1));
18257         o_conv.is_owned = (o & 1) || (o == 0);
18258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18259         o_conv = UpdateFee_clone(&o_conv);
18260         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18261         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18262         return (uint32_t)ret_conv;
18263 }
18264
18265 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18266         LDKDecodeError e_conv;
18267         e_conv.inner = (void*)(e & (~1));
18268         e_conv.is_owned = (e & 1) || (e == 0);
18269         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18270         e_conv = DecodeError_clone(&e_conv);
18271         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18272         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18273         return (uint32_t)ret_conv;
18274 }
18275
18276 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18277         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18278         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18279         return ret_val;
18280 }
18281
18282 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18283         if ((_res & 1) != 0) return;
18284         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18285         CHECK_ACCESS(_res_ptr);
18286         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18287         FREE((void*)_res);
18288         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18289 }
18290
18291 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18292         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18293         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18294         return (uint32_t)ret_conv;
18295 }
18296 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18297         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18298         uint32_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18299         return ret_val;
18300 }
18301
18302 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18303         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18304         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18305         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18306         return (uint32_t)ret_conv;
18307 }
18308
18309 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18310         LDKUpdateFulfillHTLC o_conv;
18311         o_conv.inner = (void*)(o & (~1));
18312         o_conv.is_owned = (o & 1) || (o == 0);
18313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18314         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18315         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18316         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18317         return (uint32_t)ret_conv;
18318 }
18319
18320 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18321         LDKDecodeError e_conv;
18322         e_conv.inner = (void*)(e & (~1));
18323         e_conv.is_owned = (e & 1) || (e == 0);
18324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18325         e_conv = DecodeError_clone(&e_conv);
18326         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18327         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18328         return (uint32_t)ret_conv;
18329 }
18330
18331 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18332         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18333         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18334         return ret_val;
18335 }
18336
18337 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18338         if ((_res & 1) != 0) return;
18339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18340         CHECK_ACCESS(_res_ptr);
18341         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18342         FREE((void*)_res);
18343         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18344 }
18345
18346 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18347         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18348         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18349         return (uint32_t)ret_conv;
18350 }
18351 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18352         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18353         uint32_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18354         return ret_val;
18355 }
18356
18357 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18358         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18359         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18360         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18361         return (uint32_t)ret_conv;
18362 }
18363
18364 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18365         LDKUpdateAddHTLC o_conv;
18366         o_conv.inner = (void*)(o & (~1));
18367         o_conv.is_owned = (o & 1) || (o == 0);
18368         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18369         o_conv = UpdateAddHTLC_clone(&o_conv);
18370         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18371         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18372         return (uint32_t)ret_conv;
18373 }
18374
18375 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18376         LDKDecodeError e_conv;
18377         e_conv.inner = (void*)(e & (~1));
18378         e_conv.is_owned = (e & 1) || (e == 0);
18379         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18380         e_conv = DecodeError_clone(&e_conv);
18381         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18382         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18383         return (uint32_t)ret_conv;
18384 }
18385
18386 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18387         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18388         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18389         return ret_val;
18390 }
18391
18392 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18393         if ((_res & 1) != 0) return;
18394         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18395         CHECK_ACCESS(_res_ptr);
18396         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18397         FREE((void*)_res);
18398         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18399 }
18400
18401 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18402         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18403         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18404         return (uint32_t)ret_conv;
18405 }
18406 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18407         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18408         uint32_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18409         return ret_val;
18410 }
18411
18412 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18413         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18414         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18415         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18420         LDKPing o_conv;
18421         o_conv.inner = (void*)(o & (~1));
18422         o_conv.is_owned = (o & 1) || (o == 0);
18423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18424         o_conv = Ping_clone(&o_conv);
18425         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18426         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18431         LDKDecodeError e_conv;
18432         e_conv.inner = (void*)(e & (~1));
18433         e_conv.is_owned = (e & 1) || (e == 0);
18434         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18435         e_conv = DecodeError_clone(&e_conv);
18436         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18437         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18438         return (uint32_t)ret_conv;
18439 }
18440
18441 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18442         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18443         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18444         return ret_val;
18445 }
18446
18447 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18448         if ((_res & 1) != 0) return;
18449         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18450         CHECK_ACCESS(_res_ptr);
18451         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18452         FREE((void*)_res);
18453         CResult_PingDecodeErrorZ_free(_res_conv);
18454 }
18455
18456 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18457         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18458         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18459         return (uint32_t)ret_conv;
18460 }
18461 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18462         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18463         uint32_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18464         return ret_val;
18465 }
18466
18467 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18468         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18469         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18470         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18471         return (uint32_t)ret_conv;
18472 }
18473
18474 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18475         LDKPong o_conv;
18476         o_conv.inner = (void*)(o & (~1));
18477         o_conv.is_owned = (o & 1) || (o == 0);
18478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18479         o_conv = Pong_clone(&o_conv);
18480         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18481         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18482         return (uint32_t)ret_conv;
18483 }
18484
18485 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18486         LDKDecodeError e_conv;
18487         e_conv.inner = (void*)(e & (~1));
18488         e_conv.is_owned = (e & 1) || (e == 0);
18489         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18490         e_conv = DecodeError_clone(&e_conv);
18491         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18492         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18493         return (uint32_t)ret_conv;
18494 }
18495
18496 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18497         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18498         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18499         return ret_val;
18500 }
18501
18502 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18503         if ((_res & 1) != 0) return;
18504         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18505         CHECK_ACCESS(_res_ptr);
18506         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18507         FREE((void*)_res);
18508         CResult_PongDecodeErrorZ_free(_res_conv);
18509 }
18510
18511 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18512         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18513         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18514         return (uint32_t)ret_conv;
18515 }
18516 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18517         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18518         uint32_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18519         return ret_val;
18520 }
18521
18522 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18523         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18524         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18525         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18526         return (uint32_t)ret_conv;
18527 }
18528
18529 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18530         LDKUnsignedChannelAnnouncement o_conv;
18531         o_conv.inner = (void*)(o & (~1));
18532         o_conv.is_owned = (o & 1) || (o == 0);
18533         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18534         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18535         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18536         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18537         return (uint32_t)ret_conv;
18538 }
18539
18540 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18541         LDKDecodeError e_conv;
18542         e_conv.inner = (void*)(e & (~1));
18543         e_conv.is_owned = (e & 1) || (e == 0);
18544         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18545         e_conv = DecodeError_clone(&e_conv);
18546         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18547         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18548         return (uint32_t)ret_conv;
18549 }
18550
18551 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18552         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18553         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18554         return ret_val;
18555 }
18556
18557 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18558         if ((_res & 1) != 0) return;
18559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18560         CHECK_ACCESS(_res_ptr);
18561         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18562         FREE((void*)_res);
18563         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18564 }
18565
18566 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18567         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18568         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18569         return (uint32_t)ret_conv;
18570 }
18571 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18572         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18573         uint32_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18574         return ret_val;
18575 }
18576
18577 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18578         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18579         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18580         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18581         return (uint32_t)ret_conv;
18582 }
18583
18584 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18585         LDKChannelAnnouncement o_conv;
18586         o_conv.inner = (void*)(o & (~1));
18587         o_conv.is_owned = (o & 1) || (o == 0);
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18589         o_conv = ChannelAnnouncement_clone(&o_conv);
18590         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18591         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18592         return (uint32_t)ret_conv;
18593 }
18594
18595 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18596         LDKDecodeError e_conv;
18597         e_conv.inner = (void*)(e & (~1));
18598         e_conv.is_owned = (e & 1) || (e == 0);
18599         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18600         e_conv = DecodeError_clone(&e_conv);
18601         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18602         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18603         return (uint32_t)ret_conv;
18604 }
18605
18606 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18607         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18608         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18609         return ret_val;
18610 }
18611
18612 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18613         if ((_res & 1) != 0) return;
18614         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18615         CHECK_ACCESS(_res_ptr);
18616         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18617         FREE((void*)_res);
18618         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18619 }
18620
18621 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18622         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18623         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18624         return (uint32_t)ret_conv;
18625 }
18626 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18627         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18628         uint32_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18629         return ret_val;
18630 }
18631
18632 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18633         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18634         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18635         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18636         return (uint32_t)ret_conv;
18637 }
18638
18639 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18640         LDKUnsignedChannelUpdate o_conv;
18641         o_conv.inner = (void*)(o & (~1));
18642         o_conv.is_owned = (o & 1) || (o == 0);
18643         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18644         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18645         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18646         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18647         return (uint32_t)ret_conv;
18648 }
18649
18650 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18651         LDKDecodeError e_conv;
18652         e_conv.inner = (void*)(e & (~1));
18653         e_conv.is_owned = (e & 1) || (e == 0);
18654         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18655         e_conv = DecodeError_clone(&e_conv);
18656         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18657         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18658         return (uint32_t)ret_conv;
18659 }
18660
18661 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18662         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18663         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18664         return ret_val;
18665 }
18666
18667 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18668         if ((_res & 1) != 0) return;
18669         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18670         CHECK_ACCESS(_res_ptr);
18671         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18672         FREE((void*)_res);
18673         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18674 }
18675
18676 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18677         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18678         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18679         return (uint32_t)ret_conv;
18680 }
18681 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18682         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18683         uint32_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18684         return ret_val;
18685 }
18686
18687 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18688         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18689         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18690         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18691         return (uint32_t)ret_conv;
18692 }
18693
18694 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18695         LDKChannelUpdate o_conv;
18696         o_conv.inner = (void*)(o & (~1));
18697         o_conv.is_owned = (o & 1) || (o == 0);
18698         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18699         o_conv = ChannelUpdate_clone(&o_conv);
18700         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18701         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18702         return (uint32_t)ret_conv;
18703 }
18704
18705 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18706         LDKDecodeError e_conv;
18707         e_conv.inner = (void*)(e & (~1));
18708         e_conv.is_owned = (e & 1) || (e == 0);
18709         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18710         e_conv = DecodeError_clone(&e_conv);
18711         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18712         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18713         return (uint32_t)ret_conv;
18714 }
18715
18716 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18717         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18718         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18719         return ret_val;
18720 }
18721
18722 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18723         if ((_res & 1) != 0) return;
18724         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18725         CHECK_ACCESS(_res_ptr);
18726         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18727         FREE((void*)_res);
18728         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18729 }
18730
18731 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18732         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18733         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18734         return (uint32_t)ret_conv;
18735 }
18736 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18737         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18738         uint32_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18739         return ret_val;
18740 }
18741
18742 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18743         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18744         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18745         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18746         return (uint32_t)ret_conv;
18747 }
18748
18749 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18750         LDKErrorMessage o_conv;
18751         o_conv.inner = (void*)(o & (~1));
18752         o_conv.is_owned = (o & 1) || (o == 0);
18753         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18754         o_conv = ErrorMessage_clone(&o_conv);
18755         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18756         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18757         return (uint32_t)ret_conv;
18758 }
18759
18760 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18761         LDKDecodeError e_conv;
18762         e_conv.inner = (void*)(e & (~1));
18763         e_conv.is_owned = (e & 1) || (e == 0);
18764         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18765         e_conv = DecodeError_clone(&e_conv);
18766         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18767         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18768         return (uint32_t)ret_conv;
18769 }
18770
18771 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18772         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18773         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18774         return ret_val;
18775 }
18776
18777 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18778         if ((_res & 1) != 0) return;
18779         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18780         CHECK_ACCESS(_res_ptr);
18781         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18782         FREE((void*)_res);
18783         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18784 }
18785
18786 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18787         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18788         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18789         return (uint32_t)ret_conv;
18790 }
18791 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18792         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18793         uint32_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18794         return ret_val;
18795 }
18796
18797 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18798         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18799         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18800         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18801         return (uint32_t)ret_conv;
18802 }
18803
18804 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18805         LDKWarningMessage o_conv;
18806         o_conv.inner = (void*)(o & (~1));
18807         o_conv.is_owned = (o & 1) || (o == 0);
18808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18809         o_conv = WarningMessage_clone(&o_conv);
18810         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18811         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18812         return (uint32_t)ret_conv;
18813 }
18814
18815 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18816         LDKDecodeError e_conv;
18817         e_conv.inner = (void*)(e & (~1));
18818         e_conv.is_owned = (e & 1) || (e == 0);
18819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18820         e_conv = DecodeError_clone(&e_conv);
18821         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18822         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18823         return (uint32_t)ret_conv;
18824 }
18825
18826 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18827         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18828         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18829         return ret_val;
18830 }
18831
18832 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18833         if ((_res & 1) != 0) return;
18834         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18835         CHECK_ACCESS(_res_ptr);
18836         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18837         FREE((void*)_res);
18838         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18839 }
18840
18841 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18842         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18843         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18844         return (uint32_t)ret_conv;
18845 }
18846 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18847         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18848         uint32_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18849         return ret_val;
18850 }
18851
18852 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18853         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18854         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18855         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18856         return (uint32_t)ret_conv;
18857 }
18858
18859 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18860         LDKUnsignedNodeAnnouncement o_conv;
18861         o_conv.inner = (void*)(o & (~1));
18862         o_conv.is_owned = (o & 1) || (o == 0);
18863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18864         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18865         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18866         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18867         return (uint32_t)ret_conv;
18868 }
18869
18870 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18871         LDKDecodeError e_conv;
18872         e_conv.inner = (void*)(e & (~1));
18873         e_conv.is_owned = (e & 1) || (e == 0);
18874         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18875         e_conv = DecodeError_clone(&e_conv);
18876         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18877         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18878         return (uint32_t)ret_conv;
18879 }
18880
18881 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18882         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18883         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18884         return ret_val;
18885 }
18886
18887 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18888         if ((_res & 1) != 0) return;
18889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18890         CHECK_ACCESS(_res_ptr);
18891         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18892         FREE((void*)_res);
18893         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18894 }
18895
18896 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18897         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18898         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18899         return (uint32_t)ret_conv;
18900 }
18901 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18902         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18903         uint32_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18904         return ret_val;
18905 }
18906
18907 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18908         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18909         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18910         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18911         return (uint32_t)ret_conv;
18912 }
18913
18914 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18915         LDKNodeAnnouncement o_conv;
18916         o_conv.inner = (void*)(o & (~1));
18917         o_conv.is_owned = (o & 1) || (o == 0);
18918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18919         o_conv = NodeAnnouncement_clone(&o_conv);
18920         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18921         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18922         return (uint32_t)ret_conv;
18923 }
18924
18925 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18926         LDKDecodeError e_conv;
18927         e_conv.inner = (void*)(e & (~1));
18928         e_conv.is_owned = (e & 1) || (e == 0);
18929         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18930         e_conv = DecodeError_clone(&e_conv);
18931         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18932         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18933         return (uint32_t)ret_conv;
18934 }
18935
18936 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18937         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18938         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18939         return ret_val;
18940 }
18941
18942 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18943         if ((_res & 1) != 0) return;
18944         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18945         CHECK_ACCESS(_res_ptr);
18946         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18947         FREE((void*)_res);
18948         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18949 }
18950
18951 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18952         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18953         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18954         return (uint32_t)ret_conv;
18955 }
18956 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18957         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18958         uint32_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18959         return ret_val;
18960 }
18961
18962 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18963         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18964         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18965         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18966         return (uint32_t)ret_conv;
18967 }
18968
18969 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
18970         LDKQueryShortChannelIds o_conv;
18971         o_conv.inner = (void*)(o & (~1));
18972         o_conv.is_owned = (o & 1) || (o == 0);
18973         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18974         o_conv = QueryShortChannelIds_clone(&o_conv);
18975         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18976         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18977         return (uint32_t)ret_conv;
18978 }
18979
18980 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
18981         LDKDecodeError e_conv;
18982         e_conv.inner = (void*)(e & (~1));
18983         e_conv.is_owned = (e & 1) || (e == 0);
18984         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18985         e_conv = DecodeError_clone(&e_conv);
18986         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18987         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18988         return (uint32_t)ret_conv;
18989 }
18990
18991 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
18992         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18993         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18994         return ret_val;
18995 }
18996
18997 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
18998         if ((_res & 1) != 0) return;
18999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19000         CHECK_ACCESS(_res_ptr);
19001         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19002         FREE((void*)_res);
19003         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19004 }
19005
19006 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19007         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19008         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19009         return (uint32_t)ret_conv;
19010 }
19011 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19012         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19013         uint32_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19014         return ret_val;
19015 }
19016
19017 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19018         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19019         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19020         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19021         return (uint32_t)ret_conv;
19022 }
19023
19024 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19025         LDKReplyShortChannelIdsEnd o_conv;
19026         o_conv.inner = (void*)(o & (~1));
19027         o_conv.is_owned = (o & 1) || (o == 0);
19028         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19029         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19030         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19031         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19032         return (uint32_t)ret_conv;
19033 }
19034
19035 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19036         LDKDecodeError e_conv;
19037         e_conv.inner = (void*)(e & (~1));
19038         e_conv.is_owned = (e & 1) || (e == 0);
19039         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19040         e_conv = DecodeError_clone(&e_conv);
19041         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19042         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19043         return (uint32_t)ret_conv;
19044 }
19045
19046 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19047         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19048         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19049         return ret_val;
19050 }
19051
19052 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19053         if ((_res & 1) != 0) return;
19054         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19055         CHECK_ACCESS(_res_ptr);
19056         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19057         FREE((void*)_res);
19058         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19059 }
19060
19061 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19062         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19063         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19064         return (uint32_t)ret_conv;
19065 }
19066 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19067         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19068         uint32_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19069         return ret_val;
19070 }
19071
19072 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19073         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19074         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19075         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19076         return (uint32_t)ret_conv;
19077 }
19078
19079 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19080         LDKQueryChannelRange o_conv;
19081         o_conv.inner = (void*)(o & (~1));
19082         o_conv.is_owned = (o & 1) || (o == 0);
19083         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19084         o_conv = QueryChannelRange_clone(&o_conv);
19085         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19086         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19087         return (uint32_t)ret_conv;
19088 }
19089
19090 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19091         LDKDecodeError e_conv;
19092         e_conv.inner = (void*)(e & (~1));
19093         e_conv.is_owned = (e & 1) || (e == 0);
19094         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19095         e_conv = DecodeError_clone(&e_conv);
19096         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19097         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19098         return (uint32_t)ret_conv;
19099 }
19100
19101 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19102         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19103         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19104         return ret_val;
19105 }
19106
19107 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19108         if ((_res & 1) != 0) return;
19109         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19110         CHECK_ACCESS(_res_ptr);
19111         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19112         FREE((void*)_res);
19113         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19114 }
19115
19116 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19117         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19118         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19119         return (uint32_t)ret_conv;
19120 }
19121 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19122         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19123         uint32_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19124         return ret_val;
19125 }
19126
19127 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19128         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19129         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19130         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19131         return (uint32_t)ret_conv;
19132 }
19133
19134 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19135         LDKReplyChannelRange o_conv;
19136         o_conv.inner = (void*)(o & (~1));
19137         o_conv.is_owned = (o & 1) || (o == 0);
19138         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19139         o_conv = ReplyChannelRange_clone(&o_conv);
19140         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19141         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19142         return (uint32_t)ret_conv;
19143 }
19144
19145 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
19146         LDKDecodeError e_conv;
19147         e_conv.inner = (void*)(e & (~1));
19148         e_conv.is_owned = (e & 1) || (e == 0);
19149         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19150         e_conv = DecodeError_clone(&e_conv);
19151         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19152         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19153         return (uint32_t)ret_conv;
19154 }
19155
19156 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19157         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19158         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19159         return ret_val;
19160 }
19161
19162 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
19163         if ((_res & 1) != 0) return;
19164         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19165         CHECK_ACCESS(_res_ptr);
19166         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19167         FREE((void*)_res);
19168         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19169 }
19170
19171 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19172         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19173         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19174         return (uint32_t)ret_conv;
19175 }
19176 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19177         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19178         uint32_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19179         return ret_val;
19180 }
19181
19182 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19183         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19184         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19185         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19186         return (uint32_t)ret_conv;
19187 }
19188
19189 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19190         LDKGossipTimestampFilter o_conv;
19191         o_conv.inner = (void*)(o & (~1));
19192         o_conv.is_owned = (o & 1) || (o == 0);
19193         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19194         o_conv = GossipTimestampFilter_clone(&o_conv);
19195         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19196         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19197         return (uint32_t)ret_conv;
19198 }
19199
19200 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
19201         LDKDecodeError e_conv;
19202         e_conv.inner = (void*)(e & (~1));
19203         e_conv.is_owned = (e & 1) || (e == 0);
19204         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19205         e_conv = DecodeError_clone(&e_conv);
19206         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19207         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19208         return (uint32_t)ret_conv;
19209 }
19210
19211 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19212         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19213         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19214         return ret_val;
19215 }
19216
19217 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
19218         if ((_res & 1) != 0) return;
19219         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19220         CHECK_ACCESS(_res_ptr);
19221         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19222         FREE((void*)_res);
19223         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19224 }
19225
19226 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19227         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19228         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19229         return (uint32_t)ret_conv;
19230 }
19231 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19232         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19233         uint32_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19234         return ret_val;
19235 }
19236
19237 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19238         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19239         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19240         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19241         return (uint32_t)ret_conv;
19242 }
19243
19244 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19245         LDKInvoice o_conv;
19246         o_conv.inner = (void*)(o & (~1));
19247         o_conv.is_owned = (o & 1) || (o == 0);
19248         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19249         o_conv = Invoice_clone(&o_conv);
19250         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19251         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19252         return (uint32_t)ret_conv;
19253 }
19254
19255 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19256         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19257         CHECK_ACCESS(e_ptr);
19258         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19259         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19260         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19261         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19262         return (uint32_t)ret_conv;
19263 }
19264
19265 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19266         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19267         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19268         return ret_val;
19269 }
19270
19271 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19272         if ((_res & 1) != 0) return;
19273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19274         CHECK_ACCESS(_res_ptr);
19275         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19276         FREE((void*)_res);
19277         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19278 }
19279
19280 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19281         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19282         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19283         return (uint32_t)ret_conv;
19284 }
19285 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19286         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19287         uint32_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19288         return ret_val;
19289 }
19290
19291 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19292         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19293         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19294         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19295         return (uint32_t)ret_conv;
19296 }
19297
19298 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19299         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19300         CHECK_ACCESS(o_ptr);
19301         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19302         if (o_conv.free == LDKFilter_JCalls_free) {
19303                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19304                 LDKFilter_JCalls_cloned(&o_conv);
19305         }
19306         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19307         *ret_copy = COption_FilterZ_some(o_conv);
19308         uint32_t ret_ref = (uintptr_t)ret_copy;
19309         return ret_ref;
19310 }
19311
19312 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19313         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19314         *ret_copy = COption_FilterZ_none();
19315         uint32_t ret_ref = (uintptr_t)ret_copy;
19316         return ret_ref;
19317 }
19318
19319 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19320         if ((_res & 1) != 0) return;
19321         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19322         CHECK_ACCESS(_res_ptr);
19323         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19324         FREE((void*)_res);
19325         COption_FilterZ_free(_res_conv);
19326 }
19327
19328 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19329         LDKLockedChannelMonitor o_conv;
19330         o_conv.inner = (void*)(o & (~1));
19331         o_conv.is_owned = (o & 1) || (o == 0);
19332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19333         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19334         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19335         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19336         return (uint32_t)ret_conv;
19337 }
19338
19339 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19340         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19341         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19342         return (uint32_t)ret_conv;
19343 }
19344
19345 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19346         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19347         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19348         return ret_val;
19349 }
19350
19351 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19352         if ((_res & 1) != 0) return;
19353         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19354         CHECK_ACCESS(_res_ptr);
19355         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19356         FREE((void*)_res);
19357         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19358 }
19359
19360 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19361         LDKCVec_OutPointZ _res_constr;
19362         _res_constr.datalen = _res->arr_len;
19363         if (_res_constr.datalen > 0)
19364                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19365         else
19366                 _res_constr.data = NULL;
19367         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19368         for (size_t k = 0; k < _res_constr.datalen; k++) {
19369                 uint32_t _res_conv_10 = _res_vals[k];
19370                 LDKOutPoint _res_conv_10_conv;
19371                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19372                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19374                 _res_constr.data[k] = _res_conv_10_conv;
19375         }
19376         CVec_OutPointZ_free(_res_constr);
19377 }
19378
19379 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19380         if ((this_ptr & 1) != 0) return;
19381         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19382         CHECK_ACCESS(this_ptr_ptr);
19383         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19384         FREE((void*)this_ptr);
19385         PaymentPurpose_free(this_ptr_conv);
19386 }
19387
19388 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19389         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19390         *ret_copy = PaymentPurpose_clone(arg);
19391 uint32_t ret_ref = (uintptr_t)ret_copy;
19392         return ret_ref;
19393 }
19394 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19395         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19396         uint32_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19397         return ret_val;
19398 }
19399
19400 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19401         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19402         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19403         *ret_copy = PaymentPurpose_clone(orig_conv);
19404         uint32_t ret_ref = (uintptr_t)ret_copy;
19405         return ret_ref;
19406 }
19407
19408 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19409         LDKThirtyTwoBytes payment_preimage_ref;
19410         CHECK(payment_preimage->arr_len == 32);
19411         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19412         LDKThirtyTwoBytes payment_secret_ref;
19413         CHECK(payment_secret->arr_len == 32);
19414         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19415         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19416         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19417         uint32_t ret_ref = (uintptr_t)ret_copy;
19418         return ret_ref;
19419 }
19420
19421 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19422         LDKThirtyTwoBytes a_ref;
19423         CHECK(a->arr_len == 32);
19424         memcpy(a_ref.data, a->elems, 32); FREE(a);
19425         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19426         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19427         uint32_t ret_ref = (uintptr_t)ret_copy;
19428         return ret_ref;
19429 }
19430
19431 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19432         if ((this_ptr & 1) != 0) return;
19433         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19434         CHECK_ACCESS(this_ptr_ptr);
19435         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19436         FREE((void*)this_ptr);
19437         ClosureReason_free(this_ptr_conv);
19438 }
19439
19440 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19441         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19442         *ret_copy = ClosureReason_clone(arg);
19443 uint32_t ret_ref = (uintptr_t)ret_copy;
19444         return ret_ref;
19445 }
19446 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19447         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19448         uint32_t ret_val = ClosureReason_clone_ptr(arg_conv);
19449         return ret_val;
19450 }
19451
19452 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19453         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19454         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19455         *ret_copy = ClosureReason_clone(orig_conv);
19456         uint32_t ret_ref = (uintptr_t)ret_copy;
19457         return ret_ref;
19458 }
19459
19460 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19461         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19462         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19463         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19464         uint32_t ret_ref = (uintptr_t)ret_copy;
19465         return ret_ref;
19466 }
19467
19468 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19469         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19470         *ret_copy = ClosureReason_holder_force_closed();
19471         uint32_t ret_ref = (uintptr_t)ret_copy;
19472         return ret_ref;
19473 }
19474
19475 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19476         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19477         *ret_copy = ClosureReason_cooperative_closure();
19478         uint32_t ret_ref = (uintptr_t)ret_copy;
19479         return ret_ref;
19480 }
19481
19482 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19483         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19484         *ret_copy = ClosureReason_commitment_tx_confirmed();
19485         uint32_t ret_ref = (uintptr_t)ret_copy;
19486         return ret_ref;
19487 }
19488
19489 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19490         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19491         *ret_copy = ClosureReason_funding_timed_out();
19492         uint32_t ret_ref = (uintptr_t)ret_copy;
19493         return ret_ref;
19494 }
19495
19496 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19497         LDKStr err_conv = str_ref_to_owned_c(err);
19498         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19499         *ret_copy = ClosureReason_processing_error(err_conv);
19500         uint32_t ret_ref = (uintptr_t)ret_copy;
19501         return ret_ref;
19502 }
19503
19504 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19505         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19506         *ret_copy = ClosureReason_disconnected_peer();
19507         uint32_t ret_ref = (uintptr_t)ret_copy;
19508         return ret_ref;
19509 }
19510
19511 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19512         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19513         *ret_copy = ClosureReason_outdated_channel_manager();
19514         uint32_t ret_ref = (uintptr_t)ret_copy;
19515         return ret_ref;
19516 }
19517
19518 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19519         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19520         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19521         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19522         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19523         CVec_u8Z_free(ret_var);
19524         return ret_arr;
19525 }
19526
19527 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19528         LDKu8slice ser_ref;
19529         ser_ref.datalen = ser->arr_len;
19530         ser_ref.data = ser->elems /* XXX ser leaks */;
19531         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19532         *ret_conv = ClosureReason_read(ser_ref);
19533         return (uint32_t)ret_conv;
19534 }
19535
19536 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19537         if ((this_ptr & 1) != 0) return;
19538         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19539         CHECK_ACCESS(this_ptr_ptr);
19540         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19541         FREE((void*)this_ptr);
19542         Event_free(this_ptr_conv);
19543 }
19544
19545 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19546         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19547         *ret_copy = Event_clone(arg);
19548 uint32_t ret_ref = (uintptr_t)ret_copy;
19549         return ret_ref;
19550 }
19551 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19552         LDKEvent* arg_conv = (LDKEvent*)arg;
19553         uint32_t ret_val = Event_clone_ptr(arg_conv);
19554         return ret_val;
19555 }
19556
19557 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19558         LDKEvent* orig_conv = (LDKEvent*)orig;
19559         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19560         *ret_copy = Event_clone(orig_conv);
19561         uint32_t ret_ref = (uintptr_t)ret_copy;
19562         return ret_ref;
19563 }
19564
19565 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) {
19566         LDKThirtyTwoBytes temporary_channel_id_ref;
19567         CHECK(temporary_channel_id->arr_len == 32);
19568         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19569         LDKCVec_u8Z output_script_ref;
19570         output_script_ref.datalen = output_script->arr_len;
19571         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19572         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19573         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19574         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19575         uint32_t ret_ref = (uintptr_t)ret_copy;
19576         return ret_ref;
19577 }
19578
19579 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19580         LDKThirtyTwoBytes payment_hash_ref;
19581         CHECK(payment_hash->arr_len == 32);
19582         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19583         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19584         CHECK_ACCESS(purpose_ptr);
19585         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19586         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19587         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19588         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19589         uint32_t ret_ref = (uintptr_t)ret_copy;
19590         return ret_ref;
19591 }
19592
19593 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) {
19594         LDKThirtyTwoBytes payment_id_ref;
19595         CHECK(payment_id->arr_len == 32);
19596         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19597         LDKThirtyTwoBytes payment_preimage_ref;
19598         CHECK(payment_preimage->arr_len == 32);
19599         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19600         LDKThirtyTwoBytes payment_hash_ref;
19601         CHECK(payment_hash->arr_len == 32);
19602         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19603         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19604         CHECK_ACCESS(fee_paid_msat_ptr);
19605         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19606         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19608         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19609         uint32_t ret_ref = (uintptr_t)ret_copy;
19610         return ret_ref;
19611 }
19612
19613 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) {
19614         LDKThirtyTwoBytes payment_id_ref;
19615         CHECK(payment_id->arr_len == 32);
19616         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19617         LDKThirtyTwoBytes payment_hash_ref;
19618         CHECK(payment_hash->arr_len == 32);
19619         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19620         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19621         CHECK_ACCESS(network_update_ptr);
19622         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19623         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19624         LDKCVec_RouteHopZ path_constr;
19625         path_constr.datalen = path->arr_len;
19626         if (path_constr.datalen > 0)
19627                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19628         else
19629                 path_constr.data = NULL;
19630         uint32_t* path_vals = path->elems /* XXX path leaks */;
19631         for (size_t k = 0; k < path_constr.datalen; k++) {
19632                 uint32_t path_conv_10 = path_vals[k];
19633                 LDKRouteHop path_conv_10_conv;
19634                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19635                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19636                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19637                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19638                 path_constr.data[k] = path_conv_10_conv;
19639         }
19640         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19641         CHECK_ACCESS(short_channel_id_ptr);
19642         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19643         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19644         LDKRouteParameters retry_conv;
19645         retry_conv.inner = (void*)(retry & (~1));
19646         retry_conv.is_owned = (retry & 1) || (retry == 0);
19647         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19648         retry_conv = RouteParameters_clone(&retry_conv);
19649         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19650         *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);
19651         uint32_t ret_ref = (uintptr_t)ret_copy;
19652         return ret_ref;
19653 }
19654
19655 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19656         LDKThirtyTwoBytes payment_id_ref;
19657         CHECK(payment_id->arr_len == 32);
19658         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19659         LDKThirtyTwoBytes payment_hash_ref;
19660         CHECK(payment_hash->arr_len == 32);
19661         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19662         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19663         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19664         uint32_t ret_ref = (uintptr_t)ret_copy;
19665         return ret_ref;
19666 }
19667
19668 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19669         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19670         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19671         uint32_t ret_ref = (uintptr_t)ret_copy;
19672         return ret_ref;
19673 }
19674
19675 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19676         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19677         outputs_constr.datalen = outputs->arr_len;
19678         if (outputs_constr.datalen > 0)
19679                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19680         else
19681                 outputs_constr.data = NULL;
19682         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19683         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19684                 uint32_t outputs_conv_27 = outputs_vals[b];
19685                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19686                 CHECK_ACCESS(outputs_conv_27_ptr);
19687                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19688                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19689                 outputs_constr.data[b] = outputs_conv_27_conv;
19690         }
19691         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19692         *ret_copy = Event_spendable_outputs(outputs_constr);
19693         uint32_t ret_ref = (uintptr_t)ret_copy;
19694         return ret_ref;
19695 }
19696
19697 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19698         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19699         CHECK_ACCESS(fee_earned_msat_ptr);
19700         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19701         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19702         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19703         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19704         uint32_t ret_ref = (uintptr_t)ret_copy;
19705         return ret_ref;
19706 }
19707
19708 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) {
19709         LDKThirtyTwoBytes channel_id_ref;
19710         CHECK(channel_id->arr_len == 32);
19711         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19712         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19713         CHECK_ACCESS(reason_ptr);
19714         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19715         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19716         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19717         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19718         uint32_t ret_ref = (uintptr_t)ret_copy;
19719         return ret_ref;
19720 }
19721
19722 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19723         LDKThirtyTwoBytes channel_id_ref;
19724         CHECK(channel_id->arr_len == 32);
19725         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19726         LDKTransaction transaction_ref;
19727         transaction_ref.datalen = transaction->arr_len;
19728         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19729         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19730         transaction_ref.data_is_owned = true;
19731         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19732         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19733         uint32_t ret_ref = (uintptr_t)ret_copy;
19734         return ret_ref;
19735 }
19736
19737 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) {
19738         LDKThirtyTwoBytes payment_id_ref;
19739         CHECK(payment_id->arr_len == 32);
19740         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19741         LDKThirtyTwoBytes payment_hash_ref;
19742         CHECK(payment_hash->arr_len == 32);
19743         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19744         LDKCVec_RouteHopZ path_constr;
19745         path_constr.datalen = path->arr_len;
19746         if (path_constr.datalen > 0)
19747                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19748         else
19749                 path_constr.data = NULL;
19750         uint32_t* path_vals = path->elems /* XXX path leaks */;
19751         for (size_t k = 0; k < path_constr.datalen; k++) {
19752                 uint32_t path_conv_10 = path_vals[k];
19753                 LDKRouteHop path_conv_10_conv;
19754                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19755                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19756                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19757                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19758                 path_constr.data[k] = path_conv_10_conv;
19759         }
19760         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19761         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19762         uint32_t ret_ref = (uintptr_t)ret_copy;
19763         return ret_ref;
19764 }
19765
19766 uint32_t  __attribute__((export_name("TS_Event_open_channel_request"))) TS_Event_open_channel_request(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, uint32_t channel_type) {
19767         LDKThirtyTwoBytes temporary_channel_id_ref;
19768         CHECK(temporary_channel_id->arr_len == 32);
19769         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19770         LDKPublicKey counterparty_node_id_ref;
19771         CHECK(counterparty_node_id->arr_len == 33);
19772         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19773         LDKChannelTypeFeatures channel_type_conv;
19774         channel_type_conv.inner = (void*)(channel_type & (~1));
19775         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
19776         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
19777         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
19778         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19779         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
19780         uint32_t ret_ref = (uintptr_t)ret_copy;
19781         return ret_ref;
19782 }
19783
19784 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19785         LDKEvent* obj_conv = (LDKEvent*)obj;
19786         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19787         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19788         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19789         CVec_u8Z_free(ret_var);
19790         return ret_arr;
19791 }
19792
19793 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19794         LDKu8slice ser_ref;
19795         ser_ref.datalen = ser->arr_len;
19796         ser_ref.data = ser->elems /* XXX ser leaks */;
19797         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19798         *ret_conv = Event_read(ser_ref);
19799         return (uint32_t)ret_conv;
19800 }
19801
19802 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19803         if ((this_ptr & 1) != 0) return;
19804         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19805         CHECK_ACCESS(this_ptr_ptr);
19806         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19807         FREE((void*)this_ptr);
19808         MessageSendEvent_free(this_ptr_conv);
19809 }
19810
19811 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19813         *ret_copy = MessageSendEvent_clone(arg);
19814 uint32_t ret_ref = (uintptr_t)ret_copy;
19815         return ret_ref;
19816 }
19817 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19818         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19819         uint32_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19820         return ret_val;
19821 }
19822
19823 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19824         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19825         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19826         *ret_copy = MessageSendEvent_clone(orig_conv);
19827         uint32_t ret_ref = (uintptr_t)ret_copy;
19828         return ret_ref;
19829 }
19830
19831 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19832         LDKPublicKey node_id_ref;
19833         CHECK(node_id->arr_len == 33);
19834         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19835         LDKAcceptChannel msg_conv;
19836         msg_conv.inner = (void*)(msg & (~1));
19837         msg_conv.is_owned = (msg & 1) || (msg == 0);
19838         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19839         msg_conv = AcceptChannel_clone(&msg_conv);
19840         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19841         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19842         uint32_t ret_ref = (uintptr_t)ret_copy;
19843         return ret_ref;
19844 }
19845
19846 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19847         LDKPublicKey node_id_ref;
19848         CHECK(node_id->arr_len == 33);
19849         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19850         LDKOpenChannel msg_conv;
19851         msg_conv.inner = (void*)(msg & (~1));
19852         msg_conv.is_owned = (msg & 1) || (msg == 0);
19853         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19854         msg_conv = OpenChannel_clone(&msg_conv);
19855         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19856         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19857         uint32_t ret_ref = (uintptr_t)ret_copy;
19858         return ret_ref;
19859 }
19860
19861 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19862         LDKPublicKey node_id_ref;
19863         CHECK(node_id->arr_len == 33);
19864         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19865         LDKFundingCreated msg_conv;
19866         msg_conv.inner = (void*)(msg & (~1));
19867         msg_conv.is_owned = (msg & 1) || (msg == 0);
19868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19869         msg_conv = FundingCreated_clone(&msg_conv);
19870         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19871         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19872         uint32_t ret_ref = (uintptr_t)ret_copy;
19873         return ret_ref;
19874 }
19875
19876 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19877         LDKPublicKey node_id_ref;
19878         CHECK(node_id->arr_len == 33);
19879         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19880         LDKFundingSigned msg_conv;
19881         msg_conv.inner = (void*)(msg & (~1));
19882         msg_conv.is_owned = (msg & 1) || (msg == 0);
19883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19884         msg_conv = FundingSigned_clone(&msg_conv);
19885         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19886         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19887         uint32_t ret_ref = (uintptr_t)ret_copy;
19888         return ret_ref;
19889 }
19890
19891 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19892         LDKPublicKey node_id_ref;
19893         CHECK(node_id->arr_len == 33);
19894         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19895         LDKFundingLocked msg_conv;
19896         msg_conv.inner = (void*)(msg & (~1));
19897         msg_conv.is_owned = (msg & 1) || (msg == 0);
19898         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19899         msg_conv = FundingLocked_clone(&msg_conv);
19900         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19901         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19902         uint32_t ret_ref = (uintptr_t)ret_copy;
19903         return ret_ref;
19904 }
19905
19906 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19907         LDKPublicKey node_id_ref;
19908         CHECK(node_id->arr_len == 33);
19909         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19910         LDKAnnouncementSignatures msg_conv;
19911         msg_conv.inner = (void*)(msg & (~1));
19912         msg_conv.is_owned = (msg & 1) || (msg == 0);
19913         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19914         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19915         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19916         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19917         uint32_t ret_ref = (uintptr_t)ret_copy;
19918         return ret_ref;
19919 }
19920
19921 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19922         LDKPublicKey node_id_ref;
19923         CHECK(node_id->arr_len == 33);
19924         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19925         LDKCommitmentUpdate updates_conv;
19926         updates_conv.inner = (void*)(updates & (~1));
19927         updates_conv.is_owned = (updates & 1) || (updates == 0);
19928         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19929         updates_conv = CommitmentUpdate_clone(&updates_conv);
19930         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19931         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19932         uint32_t ret_ref = (uintptr_t)ret_copy;
19933         return ret_ref;
19934 }
19935
19936 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19937         LDKPublicKey node_id_ref;
19938         CHECK(node_id->arr_len == 33);
19939         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19940         LDKRevokeAndACK msg_conv;
19941         msg_conv.inner = (void*)(msg & (~1));
19942         msg_conv.is_owned = (msg & 1) || (msg == 0);
19943         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19944         msg_conv = RevokeAndACK_clone(&msg_conv);
19945         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19946         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19947         uint32_t ret_ref = (uintptr_t)ret_copy;
19948         return ret_ref;
19949 }
19950
19951 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
19952         LDKPublicKey node_id_ref;
19953         CHECK(node_id->arr_len == 33);
19954         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19955         LDKClosingSigned msg_conv;
19956         msg_conv.inner = (void*)(msg & (~1));
19957         msg_conv.is_owned = (msg & 1) || (msg == 0);
19958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19959         msg_conv = ClosingSigned_clone(&msg_conv);
19960         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19961         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19962         uint32_t ret_ref = (uintptr_t)ret_copy;
19963         return ret_ref;
19964 }
19965
19966 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
19967         LDKPublicKey node_id_ref;
19968         CHECK(node_id->arr_len == 33);
19969         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19970         LDKShutdown msg_conv;
19971         msg_conv.inner = (void*)(msg & (~1));
19972         msg_conv.is_owned = (msg & 1) || (msg == 0);
19973         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19974         msg_conv = Shutdown_clone(&msg_conv);
19975         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19976         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19977         uint32_t ret_ref = (uintptr_t)ret_copy;
19978         return ret_ref;
19979 }
19980
19981 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
19982         LDKPublicKey node_id_ref;
19983         CHECK(node_id->arr_len == 33);
19984         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19985         LDKChannelReestablish msg_conv;
19986         msg_conv.inner = (void*)(msg & (~1));
19987         msg_conv.is_owned = (msg & 1) || (msg == 0);
19988         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19989         msg_conv = ChannelReestablish_clone(&msg_conv);
19990         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19991         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19992         uint32_t ret_ref = (uintptr_t)ret_copy;
19993         return ret_ref;
19994 }
19995
19996 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
19997         LDKChannelAnnouncement msg_conv;
19998         msg_conv.inner = (void*)(msg & (~1));
19999         msg_conv.is_owned = (msg & 1) || (msg == 0);
20000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20001         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20002         LDKChannelUpdate update_msg_conv;
20003         update_msg_conv.inner = (void*)(update_msg & (~1));
20004         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20005         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20006         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20007         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20008         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20009         uint32_t ret_ref = (uintptr_t)ret_copy;
20010         return ret_ref;
20011 }
20012
20013 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20014         LDKNodeAnnouncement msg_conv;
20015         msg_conv.inner = (void*)(msg & (~1));
20016         msg_conv.is_owned = (msg & 1) || (msg == 0);
20017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20018         msg_conv = NodeAnnouncement_clone(&msg_conv);
20019         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20020         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20021         uint32_t ret_ref = (uintptr_t)ret_copy;
20022         return ret_ref;
20023 }
20024
20025 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20026         LDKChannelUpdate msg_conv;
20027         msg_conv.inner = (void*)(msg & (~1));
20028         msg_conv.is_owned = (msg & 1) || (msg == 0);
20029         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20030         msg_conv = ChannelUpdate_clone(&msg_conv);
20031         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20032         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20033         uint32_t ret_ref = (uintptr_t)ret_copy;
20034         return ret_ref;
20035 }
20036
20037 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20038         LDKPublicKey node_id_ref;
20039         CHECK(node_id->arr_len == 33);
20040         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20041         LDKChannelUpdate msg_conv;
20042         msg_conv.inner = (void*)(msg & (~1));
20043         msg_conv.is_owned = (msg & 1) || (msg == 0);
20044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20045         msg_conv = ChannelUpdate_clone(&msg_conv);
20046         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20047         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20048         uint32_t ret_ref = (uintptr_t)ret_copy;
20049         return ret_ref;
20050 }
20051
20052 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20053         LDKPublicKey node_id_ref;
20054         CHECK(node_id->arr_len == 33);
20055         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20056         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20057         CHECK_ACCESS(action_ptr);
20058         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20059         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20060         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20061         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20062         uint32_t ret_ref = (uintptr_t)ret_copy;
20063         return ret_ref;
20064 }
20065
20066 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20067         LDKPublicKey node_id_ref;
20068         CHECK(node_id->arr_len == 33);
20069         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20070         LDKQueryChannelRange msg_conv;
20071         msg_conv.inner = (void*)(msg & (~1));
20072         msg_conv.is_owned = (msg & 1) || (msg == 0);
20073         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20074         msg_conv = QueryChannelRange_clone(&msg_conv);
20075         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20076         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20077         uint32_t ret_ref = (uintptr_t)ret_copy;
20078         return ret_ref;
20079 }
20080
20081 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20082         LDKPublicKey node_id_ref;
20083         CHECK(node_id->arr_len == 33);
20084         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20085         LDKQueryShortChannelIds msg_conv;
20086         msg_conv.inner = (void*)(msg & (~1));
20087         msg_conv.is_owned = (msg & 1) || (msg == 0);
20088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20089         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20090         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20091         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20092         uint32_t ret_ref = (uintptr_t)ret_copy;
20093         return ret_ref;
20094 }
20095
20096 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
20097         LDKPublicKey node_id_ref;
20098         CHECK(node_id->arr_len == 33);
20099         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20100         LDKReplyChannelRange msg_conv;
20101         msg_conv.inner = (void*)(msg & (~1));
20102         msg_conv.is_owned = (msg & 1) || (msg == 0);
20103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20104         msg_conv = ReplyChannelRange_clone(&msg_conv);
20105         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20106         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20107         uint32_t ret_ref = (uintptr_t)ret_copy;
20108         return ret_ref;
20109 }
20110
20111 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
20112         LDKPublicKey node_id_ref;
20113         CHECK(node_id->arr_len == 33);
20114         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20115         LDKGossipTimestampFilter msg_conv;
20116         msg_conv.inner = (void*)(msg & (~1));
20117         msg_conv.is_owned = (msg & 1) || (msg == 0);
20118         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20119         msg_conv = GossipTimestampFilter_clone(&msg_conv);
20120         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20121         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
20122         uint32_t ret_ref = (uintptr_t)ret_copy;
20123         return ret_ref;
20124 }
20125
20126 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
20127         if ((this_ptr & 1) != 0) return;
20128         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20129         CHECK_ACCESS(this_ptr_ptr);
20130         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20131         FREE((void*)this_ptr);
20132         MessageSendEventsProvider_free(this_ptr_conv);
20133 }
20134
20135 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20136         if ((this_ptr & 1) != 0) return;
20137         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20138         CHECK_ACCESS(this_ptr_ptr);
20139         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20140         FREE((void*)this_ptr);
20141         EventsProvider_free(this_ptr_conv);
20142 }
20143
20144 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20145         if ((this_ptr & 1) != 0) return;
20146         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20147         CHECK_ACCESS(this_ptr_ptr);
20148         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20149         FREE((void*)this_ptr);
20150         EventHandler_free(this_ptr_conv);
20151 }
20152
20153 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20154         if ((this_ptr & 1) != 0) return;
20155         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20156         CHECK_ACCESS(this_ptr_ptr);
20157         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20158         FREE((void*)this_ptr);
20159         APIError_free(this_ptr_conv);
20160 }
20161
20162 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20163         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20164         *ret_copy = APIError_clone(arg);
20165 uint32_t ret_ref = (uintptr_t)ret_copy;
20166         return ret_ref;
20167 }
20168 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20169         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20170         uint32_t ret_val = APIError_clone_ptr(arg_conv);
20171         return ret_val;
20172 }
20173
20174 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20175         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20176         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20177         *ret_copy = APIError_clone(orig_conv);
20178         uint32_t ret_ref = (uintptr_t)ret_copy;
20179         return ret_ref;
20180 }
20181
20182 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20183         LDKStr err_conv = str_ref_to_owned_c(err);
20184         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20185         *ret_copy = APIError_apimisuse_error(err_conv);
20186         uint32_t ret_ref = (uintptr_t)ret_copy;
20187         return ret_ref;
20188 }
20189
20190 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20191         LDKStr err_conv = str_ref_to_owned_c(err);
20192         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20193         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20194         uint32_t ret_ref = (uintptr_t)ret_copy;
20195         return ret_ref;
20196 }
20197
20198 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20199         LDKStr err_conv = str_ref_to_owned_c(err);
20200         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20201         *ret_copy = APIError_route_error(err_conv);
20202         uint32_t ret_ref = (uintptr_t)ret_copy;
20203         return ret_ref;
20204 }
20205
20206 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20207         LDKStr err_conv = str_ref_to_owned_c(err);
20208         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20209         *ret_copy = APIError_channel_unavailable(err_conv);
20210         uint32_t ret_ref = (uintptr_t)ret_copy;
20211         return ret_ref;
20212 }
20213
20214 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20215         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20216         *ret_copy = APIError_monitor_update_failed();
20217         uint32_t ret_ref = (uintptr_t)ret_copy;
20218         return ret_ref;
20219 }
20220
20221 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20222         LDKShutdownScript script_conv;
20223         script_conv.inner = (void*)(script & (~1));
20224         script_conv.is_owned = (script & 1) || (script == 0);
20225         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20226         script_conv = ShutdownScript_clone(&script_conv);
20227         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20228         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20229         uint32_t ret_ref = (uintptr_t)ret_copy;
20230         return ret_ref;
20231 }
20232
20233 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20234         LDKu8slice msg_ref;
20235         msg_ref.datalen = msg->arr_len;
20236         msg_ref.data = msg->elems /* XXX msg leaks */;
20237         unsigned char sk_arr[32];
20238         CHECK(sk->arr_len == 32);
20239         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20240         unsigned char (*sk_ref)[32] = &sk_arr;
20241         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20242         *ret_conv = sign(msg_ref, sk_ref);
20243         return (uint32_t)ret_conv;
20244 }
20245
20246 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20247         LDKu8slice msg_ref;
20248         msg_ref.datalen = msg->arr_len;
20249         msg_ref.data = msg->elems /* XXX msg leaks */;
20250         LDKStr sig_conv = str_ref_to_owned_c(sig);
20251         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20252         *ret_conv = recover_pk(msg_ref, sig_conv);
20253         return (uint32_t)ret_conv;
20254 }
20255
20256 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20257         LDKu8slice msg_ref;
20258         msg_ref.datalen = msg->arr_len;
20259         msg_ref.data = msg->elems /* XXX msg leaks */;
20260         LDKStr sig_conv = str_ref_to_owned_c(sig);
20261         LDKPublicKey pk_ref;
20262         CHECK(pk->arr_len == 33);
20263         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20264         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
20265         return ret_val;
20266 }
20267
20268 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20269         LDKu8slice hrp_bytes_ref;
20270         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20271         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20272         LDKCVec_u5Z data_without_signature_constr;
20273         data_without_signature_constr.datalen = data_without_signature->arr_len;
20274         if (data_without_signature_constr.datalen > 0)
20275                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20276         else
20277                 data_without_signature_constr.data = NULL;
20278         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20279         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20280                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20281                 
20282                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20283         }
20284         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20285         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20286         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20287         CVec_u8Z_free(ret_var);
20288         return ret_arr;
20289 }
20290
20291 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20292         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20293         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20294         return ret_conv;
20295 }
20296
20297 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20298         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20299         return ret_conv;
20300 }
20301
20302 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20303         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20304         return ret_conv;
20305 }
20306
20307 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20308         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20309         return ret_conv;
20310 }
20311
20312 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20313         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20314         return ret_conv;
20315 }
20316
20317 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20318         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20319         return ret_conv;
20320 }
20321
20322 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20323         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20324         return ret_conv;
20325 }
20326
20327 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20328         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20329         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20330         jboolean ret_val = Level_eq(a_conv, b_conv);
20331         return ret_val;
20332 }
20333
20334 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20335         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20336         int64_t ret_val = Level_hash(o_conv);
20337         return ret_val;
20338 }
20339
20340 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20341         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20342         return ret_conv;
20343 }
20344
20345 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20346         LDKRecord this_obj_conv;
20347         this_obj_conv.inner = (void*)(this_obj & (~1));
20348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20350         Record_free(this_obj_conv);
20351 }
20352
20353 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20354         LDKRecord this_ptr_conv;
20355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20356         this_ptr_conv.is_owned = false;
20357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20358         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20359         return ret_conv;
20360 }
20361
20362 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20363         LDKRecord this_ptr_conv;
20364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20365         this_ptr_conv.is_owned = false;
20366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20367         LDKLevel val_conv = LDKLevel_from_js(val);
20368         Record_set_level(&this_ptr_conv, val_conv);
20369 }
20370
20371 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20372         LDKRecord this_ptr_conv;
20373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20374         this_ptr_conv.is_owned = false;
20375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20376         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20377         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20378         Str_free(ret_str);
20379         return ret_conv;
20380 }
20381
20382 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20383         LDKRecord this_ptr_conv;
20384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20385         this_ptr_conv.is_owned = false;
20386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20387         LDKStr val_conv = str_ref_to_owned_c(val);
20388         Record_set_args(&this_ptr_conv, val_conv);
20389 }
20390
20391 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20392         LDKRecord this_ptr_conv;
20393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20394         this_ptr_conv.is_owned = false;
20395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20396         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20397         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20398         Str_free(ret_str);
20399         return ret_conv;
20400 }
20401
20402 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20403         LDKRecord this_ptr_conv;
20404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20405         this_ptr_conv.is_owned = false;
20406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20407         LDKStr val_conv = str_ref_to_owned_c(val);
20408         Record_set_module_path(&this_ptr_conv, val_conv);
20409 }
20410
20411 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20412         LDKRecord this_ptr_conv;
20413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20414         this_ptr_conv.is_owned = false;
20415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20416         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20417         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20418         Str_free(ret_str);
20419         return ret_conv;
20420 }
20421
20422 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20423         LDKRecord this_ptr_conv;
20424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20425         this_ptr_conv.is_owned = false;
20426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20427         LDKStr val_conv = str_ref_to_owned_c(val);
20428         Record_set_file(&this_ptr_conv, val_conv);
20429 }
20430
20431 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20432         LDKRecord this_ptr_conv;
20433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20434         this_ptr_conv.is_owned = false;
20435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20436         int32_t ret_val = Record_get_line(&this_ptr_conv);
20437         return ret_val;
20438 }
20439
20440 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20441         LDKRecord this_ptr_conv;
20442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20443         this_ptr_conv.is_owned = false;
20444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20445         Record_set_line(&this_ptr_conv, val);
20446 }
20447
20448 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20449         LDKRecord ret_var = Record_clone(arg);
20450 uint32_t ret_ref = 0;
20451 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20452 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20453 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20454 ret_ref = (uintptr_t)ret_var.inner;
20455 if (ret_var.is_owned) {
20456         ret_ref |= 1;
20457 }
20458         return ret_ref;
20459 }
20460 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20461         LDKRecord arg_conv;
20462         arg_conv.inner = (void*)(arg & (~1));
20463         arg_conv.is_owned = false;
20464         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20465         uint32_t ret_val = Record_clone_ptr(&arg_conv);
20466         return ret_val;
20467 }
20468
20469 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20470         LDKRecord orig_conv;
20471         orig_conv.inner = (void*)(orig & (~1));
20472         orig_conv.is_owned = false;
20473         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20474         LDKRecord ret_var = Record_clone(&orig_conv);
20475         uint32_t ret_ref = 0;
20476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20479         ret_ref = (uintptr_t)ret_var.inner;
20480         if (ret_var.is_owned) {
20481                 ret_ref |= 1;
20482         }
20483         return ret_ref;
20484 }
20485
20486 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20487         if ((this_ptr & 1) != 0) return;
20488         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20489         CHECK_ACCESS(this_ptr_ptr);
20490         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20491         FREE((void*)this_ptr);
20492         Logger_free(this_ptr_conv);
20493 }
20494
20495 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20496         LDKChannelHandshakeConfig this_obj_conv;
20497         this_obj_conv.inner = (void*)(this_obj & (~1));
20498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20500         ChannelHandshakeConfig_free(this_obj_conv);
20501 }
20502
20503 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20504         LDKChannelHandshakeConfig this_ptr_conv;
20505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20506         this_ptr_conv.is_owned = false;
20507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20508         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20509         return ret_val;
20510 }
20511
20512 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20513         LDKChannelHandshakeConfig this_ptr_conv;
20514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20515         this_ptr_conv.is_owned = false;
20516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20517         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20518 }
20519
20520 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20521         LDKChannelHandshakeConfig this_ptr_conv;
20522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20523         this_ptr_conv.is_owned = false;
20524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20525         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20526         return ret_val;
20527 }
20528
20529 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) {
20530         LDKChannelHandshakeConfig this_ptr_conv;
20531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20532         this_ptr_conv.is_owned = false;
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20534         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20535 }
20536
20537 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20538         LDKChannelHandshakeConfig this_ptr_conv;
20539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20540         this_ptr_conv.is_owned = false;
20541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20542         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20543         return ret_val;
20544 }
20545
20546 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) {
20547         LDKChannelHandshakeConfig this_ptr_conv;
20548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20549         this_ptr_conv.is_owned = false;
20550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20551         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20552 }
20553
20554 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
20555         LDKChannelHandshakeConfig this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20559         jboolean ret_val = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
20560         return ret_val;
20561 }
20562
20563 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
20564         LDKChannelHandshakeConfig this_ptr_conv;
20565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20566         this_ptr_conv.is_owned = false;
20567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20568         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
20569 }
20570
20571 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_new"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, jboolean negotiate_scid_privacy_arg) {
20572         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
20573         uint32_t ret_ref = 0;
20574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20577         ret_ref = (uintptr_t)ret_var.inner;
20578         if (ret_var.is_owned) {
20579                 ret_ref |= 1;
20580         }
20581         return ret_ref;
20582 }
20583
20584 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20585         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20586 uint32_t ret_ref = 0;
20587 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20588 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20589 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20590 ret_ref = (uintptr_t)ret_var.inner;
20591 if (ret_var.is_owned) {
20592         ret_ref |= 1;
20593 }
20594         return ret_ref;
20595 }
20596 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20597         LDKChannelHandshakeConfig arg_conv;
20598         arg_conv.inner = (void*)(arg & (~1));
20599         arg_conv.is_owned = false;
20600         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20601         uint32_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20602         return ret_val;
20603 }
20604
20605 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20606         LDKChannelHandshakeConfig orig_conv;
20607         orig_conv.inner = (void*)(orig & (~1));
20608         orig_conv.is_owned = false;
20609         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20610         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20611         uint32_t ret_ref = 0;
20612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20613         CHECK((((uintptr_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 = (uintptr_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_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20623         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20624         uint32_t ret_ref = 0;
20625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20628         ret_ref = (uintptr_t)ret_var.inner;
20629         if (ret_var.is_owned) {
20630                 ret_ref |= 1;
20631         }
20632         return ret_ref;
20633 }
20634
20635 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20636         LDKChannelHandshakeLimits this_obj_conv;
20637         this_obj_conv.inner = (void*)(this_obj & (~1));
20638         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20640         ChannelHandshakeLimits_free(this_obj_conv);
20641 }
20642
20643 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20644         LDKChannelHandshakeLimits this_ptr_conv;
20645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20646         this_ptr_conv.is_owned = false;
20647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20648         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20649         return ret_val;
20650 }
20651
20652 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20653         LDKChannelHandshakeLimits this_ptr_conv;
20654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20655         this_ptr_conv.is_owned = false;
20656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20657         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20658 }
20659
20660 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20661         LDKChannelHandshakeLimits this_ptr_conv;
20662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20663         this_ptr_conv.is_owned = false;
20664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20665         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20666         return ret_val;
20667 }
20668
20669 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) {
20670         LDKChannelHandshakeLimits this_ptr_conv;
20671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20672         this_ptr_conv.is_owned = false;
20673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20674         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20675 }
20676
20677 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) {
20678         LDKChannelHandshakeLimits this_ptr_conv;
20679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20680         this_ptr_conv.is_owned = false;
20681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20682         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20683         return ret_val;
20684 }
20685
20686 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) {
20687         LDKChannelHandshakeLimits this_ptr_conv;
20688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20689         this_ptr_conv.is_owned = false;
20690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20691         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20692 }
20693
20694 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20695         LDKChannelHandshakeLimits this_ptr_conv;
20696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20697         this_ptr_conv.is_owned = false;
20698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20699         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20700         return ret_val;
20701 }
20702
20703 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) {
20704         LDKChannelHandshakeLimits this_ptr_conv;
20705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20706         this_ptr_conv.is_owned = false;
20707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20708         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20709 }
20710
20711 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20712         LDKChannelHandshakeLimits this_ptr_conv;
20713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20714         this_ptr_conv.is_owned = false;
20715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20716         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20717         return ret_val;
20718 }
20719
20720 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) {
20721         LDKChannelHandshakeLimits this_ptr_conv;
20722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20723         this_ptr_conv.is_owned = false;
20724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20725         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20726 }
20727
20728 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20729         LDKChannelHandshakeLimits this_ptr_conv;
20730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20731         this_ptr_conv.is_owned = false;
20732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20733         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20734         return ret_val;
20735 }
20736
20737 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20738         LDKChannelHandshakeLimits this_ptr_conv;
20739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20740         this_ptr_conv.is_owned = false;
20741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20742         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20743 }
20744
20745 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20746         LDKChannelHandshakeLimits this_ptr_conv;
20747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20748         this_ptr_conv.is_owned = false;
20749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20750         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20751         return ret_val;
20752 }
20753
20754 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20755         LDKChannelHandshakeLimits this_ptr_conv;
20756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20757         this_ptr_conv.is_owned = false;
20758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20759         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20760 }
20761
20762 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20763         LDKChannelHandshakeLimits this_ptr_conv;
20764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20765         this_ptr_conv.is_owned = false;
20766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20767         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20768         return ret_val;
20769 }
20770
20771 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) {
20772         LDKChannelHandshakeLimits this_ptr_conv;
20773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20774         this_ptr_conv.is_owned = false;
20775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20776         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20777 }
20778
20779 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) {
20780         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);
20781         uint32_t ret_ref = 0;
20782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20785         ret_ref = (uintptr_t)ret_var.inner;
20786         if (ret_var.is_owned) {
20787                 ret_ref |= 1;
20788         }
20789         return ret_ref;
20790 }
20791
20792 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20793         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20794 uint32_t ret_ref = 0;
20795 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20796 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20797 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20798 ret_ref = (uintptr_t)ret_var.inner;
20799 if (ret_var.is_owned) {
20800         ret_ref |= 1;
20801 }
20802         return ret_ref;
20803 }
20804 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20805         LDKChannelHandshakeLimits arg_conv;
20806         arg_conv.inner = (void*)(arg & (~1));
20807         arg_conv.is_owned = false;
20808         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20809         uint32_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20810         return ret_val;
20811 }
20812
20813 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20814         LDKChannelHandshakeLimits orig_conv;
20815         orig_conv.inner = (void*)(orig & (~1));
20816         orig_conv.is_owned = false;
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20818         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20819         uint32_t ret_ref = 0;
20820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20823         ret_ref = (uintptr_t)ret_var.inner;
20824         if (ret_var.is_owned) {
20825                 ret_ref |= 1;
20826         }
20827         return ret_ref;
20828 }
20829
20830 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20831         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20832         uint32_t ret_ref = 0;
20833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20836         ret_ref = (uintptr_t)ret_var.inner;
20837         if (ret_var.is_owned) {
20838                 ret_ref |= 1;
20839         }
20840         return ret_ref;
20841 }
20842
20843 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20844         LDKChannelConfig this_obj_conv;
20845         this_obj_conv.inner = (void*)(this_obj & (~1));
20846         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20848         ChannelConfig_free(this_obj_conv);
20849 }
20850
20851 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20852         LDKChannelConfig this_ptr_conv;
20853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20854         this_ptr_conv.is_owned = false;
20855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20856         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20857         return ret_val;
20858 }
20859
20860 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) {
20861         LDKChannelConfig 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         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20866 }
20867
20868 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20869         LDKChannelConfig this_ptr_conv;
20870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20871         this_ptr_conv.is_owned = false;
20872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20873         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20874         return ret_val;
20875 }
20876
20877 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) {
20878         LDKChannelConfig this_ptr_conv;
20879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20880         this_ptr_conv.is_owned = false;
20881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20882         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20883 }
20884
20885 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20886         LDKChannelConfig this_ptr_conv;
20887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20888         this_ptr_conv.is_owned = false;
20889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20890         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20891         return ret_val;
20892 }
20893
20894 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20895         LDKChannelConfig this_ptr_conv;
20896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20897         this_ptr_conv.is_owned = false;
20898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20899         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20900 }
20901
20902 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20903         LDKChannelConfig this_ptr_conv;
20904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20905         this_ptr_conv.is_owned = false;
20906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20907         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20908         return ret_val;
20909 }
20910
20911 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20912         LDKChannelConfig this_ptr_conv;
20913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20914         this_ptr_conv.is_owned = false;
20915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20916         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20917 }
20918
20919 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20920         LDKChannelConfig this_ptr_conv;
20921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20922         this_ptr_conv.is_owned = false;
20923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20924         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20925         return ret_val;
20926 }
20927
20928 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20929         LDKChannelConfig this_ptr_conv;
20930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20931         this_ptr_conv.is_owned = false;
20932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20933         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20934 }
20935
20936 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) {
20937         LDKChannelConfig 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         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20942         return ret_val;
20943 }
20944
20945 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) {
20946         LDKChannelConfig this_ptr_conv;
20947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20948         this_ptr_conv.is_owned = false;
20949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20950         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20951 }
20952
20953 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) {
20954         LDKChannelConfig this_ptr_conv;
20955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20956         this_ptr_conv.is_owned = false;
20957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20958         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20959         return ret_val;
20960 }
20961
20962 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) {
20963         LDKChannelConfig this_ptr_conv;
20964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20965         this_ptr_conv.is_owned = false;
20966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20967         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20968 }
20969
20970 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) {
20971         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);
20972         uint32_t ret_ref = 0;
20973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20976         ret_ref = (uintptr_t)ret_var.inner;
20977         if (ret_var.is_owned) {
20978                 ret_ref |= 1;
20979         }
20980         return ret_ref;
20981 }
20982
20983 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20984         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20985 uint32_t ret_ref = 0;
20986 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20987 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20988 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20989 ret_ref = (uintptr_t)ret_var.inner;
20990 if (ret_var.is_owned) {
20991         ret_ref |= 1;
20992 }
20993         return ret_ref;
20994 }
20995 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
20996         LDKChannelConfig arg_conv;
20997         arg_conv.inner = (void*)(arg & (~1));
20998         arg_conv.is_owned = false;
20999         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21000         uint32_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
21001         return ret_val;
21002 }
21003
21004 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
21005         LDKChannelConfig orig_conv;
21006         orig_conv.inner = (void*)(orig & (~1));
21007         orig_conv.is_owned = false;
21008         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21009         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21010         uint32_t ret_ref = 0;
21011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21014         ret_ref = (uintptr_t)ret_var.inner;
21015         if (ret_var.is_owned) {
21016                 ret_ref |= 1;
21017         }
21018         return ret_ref;
21019 }
21020
21021 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
21022         LDKChannelConfig ret_var = ChannelConfig_default();
21023         uint32_t ret_ref = 0;
21024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21027         ret_ref = (uintptr_t)ret_var.inner;
21028         if (ret_var.is_owned) {
21029                 ret_ref |= 1;
21030         }
21031         return ret_ref;
21032 }
21033
21034 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
21035         LDKChannelConfig obj_conv;
21036         obj_conv.inner = (void*)(obj & (~1));
21037         obj_conv.is_owned = false;
21038         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21039         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21040         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21041         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21042         CVec_u8Z_free(ret_var);
21043         return ret_arr;
21044 }
21045
21046 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
21047         LDKu8slice ser_ref;
21048         ser_ref.datalen = ser->arr_len;
21049         ser_ref.data = ser->elems /* XXX ser leaks */;
21050         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21051         *ret_conv = ChannelConfig_read(ser_ref);
21052         return (uint32_t)ret_conv;
21053 }
21054
21055 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
21056         LDKUserConfig this_obj_conv;
21057         this_obj_conv.inner = (void*)(this_obj & (~1));
21058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21060         UserConfig_free(this_obj_conv);
21061 }
21062
21063 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
21064         LDKUserConfig this_ptr_conv;
21065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21066         this_ptr_conv.is_owned = false;
21067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21068         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21069         uint32_t ret_ref = 0;
21070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21073         ret_ref = (uintptr_t)ret_var.inner;
21074         if (ret_var.is_owned) {
21075                 ret_ref |= 1;
21076         }
21077         return ret_ref;
21078 }
21079
21080 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
21081         LDKUserConfig this_ptr_conv;
21082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21083         this_ptr_conv.is_owned = false;
21084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21085         LDKChannelHandshakeConfig val_conv;
21086         val_conv.inner = (void*)(val & (~1));
21087         val_conv.is_owned = (val & 1) || (val == 0);
21088         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21089         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21090         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21091 }
21092
21093 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
21094         LDKUserConfig this_ptr_conv;
21095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21096         this_ptr_conv.is_owned = false;
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21098         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21099         uint32_t ret_ref = 0;
21100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21103         ret_ref = (uintptr_t)ret_var.inner;
21104         if (ret_var.is_owned) {
21105                 ret_ref |= 1;
21106         }
21107         return ret_ref;
21108 }
21109
21110 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) {
21111         LDKUserConfig this_ptr_conv;
21112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21113         this_ptr_conv.is_owned = false;
21114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21115         LDKChannelHandshakeLimits val_conv;
21116         val_conv.inner = (void*)(val & (~1));
21117         val_conv.is_owned = (val & 1) || (val == 0);
21118         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21119         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21120         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21121 }
21122
21123 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
21124         LDKUserConfig this_ptr_conv;
21125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21126         this_ptr_conv.is_owned = false;
21127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21128         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21129         uint32_t ret_ref = 0;
21130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21133         ret_ref = (uintptr_t)ret_var.inner;
21134         if (ret_var.is_owned) {
21135                 ret_ref |= 1;
21136         }
21137         return ret_ref;
21138 }
21139
21140 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
21141         LDKUserConfig this_ptr_conv;
21142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21143         this_ptr_conv.is_owned = false;
21144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21145         LDKChannelConfig val_conv;
21146         val_conv.inner = (void*)(val & (~1));
21147         val_conv.is_owned = (val & 1) || (val == 0);
21148         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21149         val_conv = ChannelConfig_clone(&val_conv);
21150         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21151 }
21152
21153 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21154         LDKUserConfig this_ptr_conv;
21155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21156         this_ptr_conv.is_owned = false;
21157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21158         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21159         return ret_val;
21160 }
21161
21162 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) {
21163         LDKUserConfig this_ptr_conv;
21164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21165         this_ptr_conv.is_owned = false;
21166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21167         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21168 }
21169
21170 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21171         LDKUserConfig this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21175         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21176         return ret_val;
21177 }
21178
21179 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21180         LDKUserConfig this_ptr_conv;
21181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21182         this_ptr_conv.is_owned = false;
21183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21184         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21185 }
21186
21187 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21188         LDKUserConfig this_ptr_conv;
21189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21190         this_ptr_conv.is_owned = false;
21191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21192         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21193         return ret_val;
21194 }
21195
21196 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21197         LDKUserConfig this_ptr_conv;
21198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21199         this_ptr_conv.is_owned = false;
21200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21201         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21202 }
21203
21204 uint32_t  __attribute__((export_name("TS_UserConfig_new"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
21205         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21206         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21207         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21208         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21209         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21210         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21211         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21212         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21213         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21214         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21215         LDKChannelConfig channel_options_arg_conv;
21216         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21217         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21218         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21219         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21220         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
21221         uint32_t ret_ref = 0;
21222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21225         ret_ref = (uintptr_t)ret_var.inner;
21226         if (ret_var.is_owned) {
21227                 ret_ref |= 1;
21228         }
21229         return ret_ref;
21230 }
21231
21232 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21233         LDKUserConfig ret_var = UserConfig_clone(arg);
21234 uint32_t ret_ref = 0;
21235 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21236 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21237 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21238 ret_ref = (uintptr_t)ret_var.inner;
21239 if (ret_var.is_owned) {
21240         ret_ref |= 1;
21241 }
21242         return ret_ref;
21243 }
21244 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21245         LDKUserConfig arg_conv;
21246         arg_conv.inner = (void*)(arg & (~1));
21247         arg_conv.is_owned = false;
21248         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21249         uint32_t ret_val = UserConfig_clone_ptr(&arg_conv);
21250         return ret_val;
21251 }
21252
21253 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21254         LDKUserConfig orig_conv;
21255         orig_conv.inner = (void*)(orig & (~1));
21256         orig_conv.is_owned = false;
21257         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21258         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21259         uint32_t ret_ref = 0;
21260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21263         ret_ref = (uintptr_t)ret_var.inner;
21264         if (ret_var.is_owned) {
21265                 ret_ref |= 1;
21266         }
21267         return ret_ref;
21268 }
21269
21270 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21271         LDKUserConfig ret_var = UserConfig_default();
21272         uint32_t ret_ref = 0;
21273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21276         ret_ref = (uintptr_t)ret_var.inner;
21277         if (ret_var.is_owned) {
21278                 ret_ref |= 1;
21279         }
21280         return ret_ref;
21281 }
21282
21283 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21284         LDKBestBlock this_obj_conv;
21285         this_obj_conv.inner = (void*)(this_obj & (~1));
21286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21288         BestBlock_free(this_obj_conv);
21289 }
21290
21291 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21292         LDKBestBlock ret_var = BestBlock_clone(arg);
21293 uint32_t ret_ref = 0;
21294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21297 ret_ref = (uintptr_t)ret_var.inner;
21298 if (ret_var.is_owned) {
21299         ret_ref |= 1;
21300 }
21301         return ret_ref;
21302 }
21303 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21304         LDKBestBlock arg_conv;
21305         arg_conv.inner = (void*)(arg & (~1));
21306         arg_conv.is_owned = false;
21307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21308         uint32_t ret_val = BestBlock_clone_ptr(&arg_conv);
21309         return ret_val;
21310 }
21311
21312 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21313         LDKBestBlock orig_conv;
21314         orig_conv.inner = (void*)(orig & (~1));
21315         orig_conv.is_owned = false;
21316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21317         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21318         uint32_t ret_ref = 0;
21319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21322         ret_ref = (uintptr_t)ret_var.inner;
21323         if (ret_var.is_owned) {
21324                 ret_ref |= 1;
21325         }
21326         return ret_ref;
21327 }
21328
21329 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21330         LDKNetwork network_conv = LDKNetwork_from_js(network);
21331         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21332         uint32_t ret_ref = 0;
21333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21336         ret_ref = (uintptr_t)ret_var.inner;
21337         if (ret_var.is_owned) {
21338                 ret_ref |= 1;
21339         }
21340         return ret_ref;
21341 }
21342
21343 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21344         LDKThirtyTwoBytes block_hash_ref;
21345         CHECK(block_hash->arr_len == 32);
21346         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21347         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21348         uint32_t ret_ref = 0;
21349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21352         ret_ref = (uintptr_t)ret_var.inner;
21353         if (ret_var.is_owned) {
21354                 ret_ref |= 1;
21355         }
21356         return ret_ref;
21357 }
21358
21359 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21360         LDKBestBlock this_arg_conv;
21361         this_arg_conv.inner = (void*)(this_arg & (~1));
21362         this_arg_conv.is_owned = false;
21363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21364         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21365         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21366         return ret_arr;
21367 }
21368
21369 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21370         LDKBestBlock this_arg_conv;
21371         this_arg_conv.inner = (void*)(this_arg & (~1));
21372         this_arg_conv.is_owned = false;
21373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21374         int32_t ret_val = BestBlock_height(&this_arg_conv);
21375         return ret_val;
21376 }
21377
21378 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21379         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21380         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21381         return ret_conv;
21382 }
21383
21384 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21385         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21386         return ret_conv;
21387 }
21388
21389 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21390         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21391         return ret_conv;
21392 }
21393
21394 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21395         if ((this_ptr & 1) != 0) return;
21396         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21397         CHECK_ACCESS(this_ptr_ptr);
21398         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21399         FREE((void*)this_ptr);
21400         Access_free(this_ptr_conv);
21401 }
21402
21403 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21404         if ((this_ptr & 1) != 0) return;
21405         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21406         CHECK_ACCESS(this_ptr_ptr);
21407         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21408         FREE((void*)this_ptr);
21409         Listen_free(this_ptr_conv);
21410 }
21411
21412 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21413         if ((this_ptr & 1) != 0) return;
21414         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21415         CHECK_ACCESS(this_ptr_ptr);
21416         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21417         FREE((void*)this_ptr);
21418         Confirm_free(this_ptr_conv);
21419 }
21420
21421 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21422         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21423         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21424         return ret_conv;
21425 }
21426
21427 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21428         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21429         return ret_conv;
21430 }
21431
21432 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21433         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21434         return ret_conv;
21435 }
21436
21437 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21438         if ((this_ptr & 1) != 0) return;
21439         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21440         CHECK_ACCESS(this_ptr_ptr);
21441         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21442         FREE((void*)this_ptr);
21443         Watch_free(this_ptr_conv);
21444 }
21445
21446 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21447         if ((this_ptr & 1) != 0) return;
21448         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21449         CHECK_ACCESS(this_ptr_ptr);
21450         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21451         FREE((void*)this_ptr);
21452         Filter_free(this_ptr_conv);
21453 }
21454
21455 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21456         LDKWatchedOutput this_obj_conv;
21457         this_obj_conv.inner = (void*)(this_obj & (~1));
21458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21460         WatchedOutput_free(this_obj_conv);
21461 }
21462
21463 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21464         LDKWatchedOutput this_ptr_conv;
21465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21466         this_ptr_conv.is_owned = false;
21467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21468         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21469         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21470         return ret_arr;
21471 }
21472
21473 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21474         LDKWatchedOutput this_ptr_conv;
21475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21476         this_ptr_conv.is_owned = false;
21477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21478         LDKThirtyTwoBytes val_ref;
21479         CHECK(val->arr_len == 32);
21480         memcpy(val_ref.data, val->elems, 32); FREE(val);
21481         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21482 }
21483
21484 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21485         LDKWatchedOutput this_ptr_conv;
21486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21487         this_ptr_conv.is_owned = false;
21488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21489         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21490         uint32_t ret_ref = 0;
21491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21494         ret_ref = (uintptr_t)ret_var.inner;
21495         if (ret_var.is_owned) {
21496                 ret_ref |= 1;
21497         }
21498         return ret_ref;
21499 }
21500
21501 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21502         LDKWatchedOutput this_ptr_conv;
21503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21504         this_ptr_conv.is_owned = false;
21505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21506         LDKOutPoint val_conv;
21507         val_conv.inner = (void*)(val & (~1));
21508         val_conv.is_owned = (val & 1) || (val == 0);
21509         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21510         val_conv = OutPoint_clone(&val_conv);
21511         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21512 }
21513
21514 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21515         LDKWatchedOutput this_ptr_conv;
21516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21517         this_ptr_conv.is_owned = false;
21518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21519         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21520         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21521         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21522         return ret_arr;
21523 }
21524
21525 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21526         LDKWatchedOutput this_ptr_conv;
21527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21528         this_ptr_conv.is_owned = false;
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21530         LDKCVec_u8Z val_ref;
21531         val_ref.datalen = val->arr_len;
21532         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21533         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21534         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21535 }
21536
21537 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) {
21538         LDKThirtyTwoBytes block_hash_arg_ref;
21539         CHECK(block_hash_arg->arr_len == 32);
21540         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21541         LDKOutPoint outpoint_arg_conv;
21542         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21543         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21544         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21545         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21546         LDKCVec_u8Z script_pubkey_arg_ref;
21547         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21548         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21549         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21550         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21551         uint32_t ret_ref = 0;
21552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21555         ret_ref = (uintptr_t)ret_var.inner;
21556         if (ret_var.is_owned) {
21557                 ret_ref |= 1;
21558         }
21559         return ret_ref;
21560 }
21561
21562 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21563         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21564 uint32_t ret_ref = 0;
21565 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21566 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21567 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21568 ret_ref = (uintptr_t)ret_var.inner;
21569 if (ret_var.is_owned) {
21570         ret_ref |= 1;
21571 }
21572         return ret_ref;
21573 }
21574 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21575         LDKWatchedOutput arg_conv;
21576         arg_conv.inner = (void*)(arg & (~1));
21577         arg_conv.is_owned = false;
21578         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21579         uint32_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21580         return ret_val;
21581 }
21582
21583 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21584         LDKWatchedOutput orig_conv;
21585         orig_conv.inner = (void*)(orig & (~1));
21586         orig_conv.is_owned = false;
21587         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21588         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21589         uint32_t ret_ref = 0;
21590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21593         ret_ref = (uintptr_t)ret_var.inner;
21594         if (ret_var.is_owned) {
21595                 ret_ref |= 1;
21596         }
21597         return ret_ref;
21598 }
21599
21600 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21601         LDKWatchedOutput o_conv;
21602         o_conv.inner = (void*)(o & (~1));
21603         o_conv.is_owned = false;
21604         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21605         int64_t ret_val = WatchedOutput_hash(&o_conv);
21606         return ret_val;
21607 }
21608
21609 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21610         if ((this_ptr & 1) != 0) return;
21611         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21612         CHECK_ACCESS(this_ptr_ptr);
21613         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21614         FREE((void*)this_ptr);
21615         BroadcasterInterface_free(this_ptr_conv);
21616 }
21617
21618 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21619         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21620         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21621         return ret_conv;
21622 }
21623
21624 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21625         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21626         return ret_conv;
21627 }
21628
21629 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21630         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21631         return ret_conv;
21632 }
21633
21634 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21635         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21636         return ret_conv;
21637 }
21638
21639 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21640         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21641         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21642         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21643         return ret_val;
21644 }
21645
21646 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21647         if ((this_ptr & 1) != 0) return;
21648         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21649         CHECK_ACCESS(this_ptr_ptr);
21650         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21651         FREE((void*)this_ptr);
21652         FeeEstimator_free(this_ptr_conv);
21653 }
21654
21655 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21656         LDKMonitorUpdateId this_obj_conv;
21657         this_obj_conv.inner = (void*)(this_obj & (~1));
21658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21660         MonitorUpdateId_free(this_obj_conv);
21661 }
21662
21663 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21664         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21665 uint32_t ret_ref = 0;
21666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21669 ret_ref = (uintptr_t)ret_var.inner;
21670 if (ret_var.is_owned) {
21671         ret_ref |= 1;
21672 }
21673         return ret_ref;
21674 }
21675 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21676         LDKMonitorUpdateId arg_conv;
21677         arg_conv.inner = (void*)(arg & (~1));
21678         arg_conv.is_owned = false;
21679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21680         uint32_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21681         return ret_val;
21682 }
21683
21684 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21685         LDKMonitorUpdateId orig_conv;
21686         orig_conv.inner = (void*)(orig & (~1));
21687         orig_conv.is_owned = false;
21688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21689         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21690         uint32_t ret_ref = 0;
21691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21694         ret_ref = (uintptr_t)ret_var.inner;
21695         if (ret_var.is_owned) {
21696                 ret_ref |= 1;
21697         }
21698         return ret_ref;
21699 }
21700
21701 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21702         LDKMonitorUpdateId o_conv;
21703         o_conv.inner = (void*)(o & (~1));
21704         o_conv.is_owned = false;
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21706         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21707         return ret_val;
21708 }
21709
21710 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21711         LDKMonitorUpdateId a_conv;
21712         a_conv.inner = (void*)(a & (~1));
21713         a_conv.is_owned = false;
21714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21715         LDKMonitorUpdateId b_conv;
21716         b_conv.inner = (void*)(b & (~1));
21717         b_conv.is_owned = false;
21718         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21719         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21720         return ret_val;
21721 }
21722
21723 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21724         if ((this_ptr & 1) != 0) return;
21725         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21726         CHECK_ACCESS(this_ptr_ptr);
21727         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21728         FREE((void*)this_ptr);
21729         Persist_free(this_ptr_conv);
21730 }
21731
21732 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21733         LDKLockedChannelMonitor this_obj_conv;
21734         this_obj_conv.inner = (void*)(this_obj & (~1));
21735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21737         LockedChannelMonitor_free(this_obj_conv);
21738 }
21739
21740 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21741         LDKChainMonitor this_obj_conv;
21742         this_obj_conv.inner = (void*)(this_obj & (~1));
21743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21745         ChainMonitor_free(this_obj_conv);
21746 }
21747
21748 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) {
21749         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21750         CHECK_ACCESS(chain_source_ptr);
21751         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21752         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21753         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21754                 // Manually implement clone for Java trait instances
21755                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21756                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21757                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21758                 }
21759         }
21760         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21761         CHECK_ACCESS(broadcaster_ptr);
21762         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21763         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21765                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21766         }
21767         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21768         CHECK_ACCESS(logger_ptr);
21769         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21770         if (logger_conv.free == LDKLogger_JCalls_free) {
21771                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21772                 LDKLogger_JCalls_cloned(&logger_conv);
21773         }
21774         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21775         CHECK_ACCESS(feeest_ptr);
21776         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21777         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21778                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21779                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21780         }
21781         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21782         CHECK_ACCESS(persister_ptr);
21783         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21784         if (persister_conv.free == LDKPersist_JCalls_free) {
21785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21786                 LDKPersist_JCalls_cloned(&persister_conv);
21787         }
21788         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21789         uint32_t ret_ref = 0;
21790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21793         ret_ref = (uintptr_t)ret_var.inner;
21794         if (ret_var.is_owned) {
21795                 ret_ref |= 1;
21796         }
21797         return ret_ref;
21798 }
21799
21800 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21801         LDKChainMonitor this_arg_conv;
21802         this_arg_conv.inner = (void*)(this_arg & (~1));
21803         this_arg_conv.is_owned = false;
21804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21805         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21806         ignored_channels_constr.datalen = ignored_channels->arr_len;
21807         if (ignored_channels_constr.datalen > 0)
21808                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21809         else
21810                 ignored_channels_constr.data = NULL;
21811         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21812         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21813                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21814                 LDKChannelDetails ignored_channels_conv_16_conv;
21815                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21816                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21817                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21818                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21819                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21820         }
21821         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21822         uint32_tArray ret_arr = NULL;
21823         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21824         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21825         for (size_t j = 0; j < ret_var.datalen; j++) {
21826                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21827                 *ret_conv_9_copy = ret_var.data[j];
21828                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21829                 ret_arr_ptr[j] = ret_conv_9_ref;
21830         }
21831         
21832         FREE(ret_var.data);
21833         return ret_arr;
21834 }
21835
21836 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21837         LDKChainMonitor this_arg_conv;
21838         this_arg_conv.inner = (void*)(this_arg & (~1));
21839         this_arg_conv.is_owned = false;
21840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21841         LDKOutPoint funding_txo_conv;
21842         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21843         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21845         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21846         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21847         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21848         return (uint32_t)ret_conv;
21849 }
21850
21851 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21852         LDKChainMonitor 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         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21857         uint32_tArray ret_arr = NULL;
21858         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21859         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21860         for (size_t k = 0; k < ret_var.datalen; k++) {
21861                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21862                 uint32_t ret_conv_10_ref = 0;
21863                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21864                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21865                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21866                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21867                 if (ret_conv_10_var.is_owned) {
21868                         ret_conv_10_ref |= 1;
21869                 }
21870                 ret_arr_ptr[k] = ret_conv_10_ref;
21871         }
21872         
21873         FREE(ret_var.data);
21874         return ret_arr;
21875 }
21876
21877 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) {
21878         LDKChainMonitor this_arg_conv;
21879         this_arg_conv.inner = (void*)(this_arg & (~1));
21880         this_arg_conv.is_owned = false;
21881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21882         LDKOutPoint funding_txo_conv;
21883         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21884         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21885         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21886         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21887         LDKMonitorUpdateId completed_update_id_conv;
21888         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21889         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21890         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21891         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21892         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21893         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21894         return (uint32_t)ret_conv;
21895 }
21896
21897 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21898         LDKChainMonitor this_arg_conv;
21899         this_arg_conv.inner = (void*)(this_arg & (~1));
21900         this_arg_conv.is_owned = false;
21901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21902         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21903         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21904         return (uint32_t)ret_ret;
21905 }
21906
21907 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21908         LDKChainMonitor this_arg_conv;
21909         this_arg_conv.inner = (void*)(this_arg & (~1));
21910         this_arg_conv.is_owned = false;
21911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21912         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21913         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21914         return (uint32_t)ret_ret;
21915 }
21916
21917 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21918         LDKChainMonitor this_arg_conv;
21919         this_arg_conv.inner = (void*)(this_arg & (~1));
21920         this_arg_conv.is_owned = false;
21921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21922         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21923         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21924         return (uint32_t)ret_ret;
21925 }
21926
21927 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21928         LDKChainMonitor this_arg_conv;
21929         this_arg_conv.inner = (void*)(this_arg & (~1));
21930         this_arg_conv.is_owned = false;
21931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21932         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21933         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21934         return (uint32_t)ret_ret;
21935 }
21936
21937 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21938         LDKChannelMonitorUpdate this_obj_conv;
21939         this_obj_conv.inner = (void*)(this_obj & (~1));
21940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21942         ChannelMonitorUpdate_free(this_obj_conv);
21943 }
21944
21945 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
21946         LDKChannelMonitorUpdate this_ptr_conv;
21947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21948         this_ptr_conv.is_owned = false;
21949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21950         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21951         return ret_val;
21952 }
21953
21954 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
21955         LDKChannelMonitorUpdate this_ptr_conv;
21956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21957         this_ptr_conv.is_owned = false;
21958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21959         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21960 }
21961
21962 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21963         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21964 uint32_t ret_ref = 0;
21965 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21966 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21967 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21968 ret_ref = (uintptr_t)ret_var.inner;
21969 if (ret_var.is_owned) {
21970         ret_ref |= 1;
21971 }
21972         return ret_ref;
21973 }
21974 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
21975         LDKChannelMonitorUpdate arg_conv;
21976         arg_conv.inner = (void*)(arg & (~1));
21977         arg_conv.is_owned = false;
21978         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21979         uint32_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21980         return ret_val;
21981 }
21982
21983 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
21984         LDKChannelMonitorUpdate orig_conv;
21985         orig_conv.inner = (void*)(orig & (~1));
21986         orig_conv.is_owned = false;
21987         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21988         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21989         uint32_t ret_ref = 0;
21990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21993         ret_ref = (uintptr_t)ret_var.inner;
21994         if (ret_var.is_owned) {
21995                 ret_ref |= 1;
21996         }
21997         return ret_ref;
21998 }
21999
22000 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
22001         LDKChannelMonitorUpdate obj_conv;
22002         obj_conv.inner = (void*)(obj & (~1));
22003         obj_conv.is_owned = false;
22004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22005         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22006         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22007         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22008         CVec_u8Z_free(ret_var);
22009         return ret_arr;
22010 }
22011
22012 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
22013         LDKu8slice ser_ref;
22014         ser_ref.datalen = ser->arr_len;
22015         ser_ref.data = ser->elems /* XXX ser leaks */;
22016         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22017         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22018         return (uint32_t)ret_conv;
22019 }
22020
22021 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
22022         if ((this_ptr & 1) != 0) return;
22023         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22024         CHECK_ACCESS(this_ptr_ptr);
22025         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22026         FREE((void*)this_ptr);
22027         MonitorEvent_free(this_ptr_conv);
22028 }
22029
22030 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22031         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22032         *ret_copy = MonitorEvent_clone(arg);
22033 uint32_t ret_ref = (uintptr_t)ret_copy;
22034         return ret_ref;
22035 }
22036 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
22037         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22038         uint32_t ret_val = MonitorEvent_clone_ptr(arg_conv);
22039         return ret_val;
22040 }
22041
22042 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
22043         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22044         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22045         *ret_copy = MonitorEvent_clone(orig_conv);
22046         uint32_t ret_ref = (uintptr_t)ret_copy;
22047         return ret_ref;
22048 }
22049
22050 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
22051         LDKHTLCUpdate a_conv;
22052         a_conv.inner = (void*)(a & (~1));
22053         a_conv.is_owned = (a & 1) || (a == 0);
22054         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22055         a_conv = HTLCUpdate_clone(&a_conv);
22056         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22057         *ret_copy = MonitorEvent_htlcevent(a_conv);
22058         uint32_t ret_ref = (uintptr_t)ret_copy;
22059         return ret_ref;
22060 }
22061
22062 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
22063         LDKOutPoint a_conv;
22064         a_conv.inner = (void*)(a & (~1));
22065         a_conv.is_owned = (a & 1) || (a == 0);
22066         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22067         a_conv = OutPoint_clone(&a_conv);
22068         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22069         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22070         uint32_t ret_ref = (uintptr_t)ret_copy;
22071         return ret_ref;
22072 }
22073
22074 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
22075         LDKOutPoint funding_txo_conv;
22076         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22077         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22078         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22079         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22080         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22081         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22082         uint32_t ret_ref = (uintptr_t)ret_copy;
22083         return ret_ref;
22084 }
22085
22086 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
22087         LDKOutPoint a_conv;
22088         a_conv.inner = (void*)(a & (~1));
22089         a_conv.is_owned = (a & 1) || (a == 0);
22090         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22091         a_conv = OutPoint_clone(&a_conv);
22092         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22093         *ret_copy = MonitorEvent_update_failed(a_conv);
22094         uint32_t ret_ref = (uintptr_t)ret_copy;
22095         return ret_ref;
22096 }
22097
22098 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
22099         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22100         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22101         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22102         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22103         CVec_u8Z_free(ret_var);
22104         return ret_arr;
22105 }
22106
22107 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
22108         LDKu8slice ser_ref;
22109         ser_ref.datalen = ser->arr_len;
22110         ser_ref.data = ser->elems /* XXX ser leaks */;
22111         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22112         *ret_conv = MonitorEvent_read(ser_ref);
22113         return (uint32_t)ret_conv;
22114 }
22115
22116 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
22117         LDKHTLCUpdate this_obj_conv;
22118         this_obj_conv.inner = (void*)(this_obj & (~1));
22119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22121         HTLCUpdate_free(this_obj_conv);
22122 }
22123
22124 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22125         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22126 uint32_t ret_ref = 0;
22127 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22128 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22129 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22130 ret_ref = (uintptr_t)ret_var.inner;
22131 if (ret_var.is_owned) {
22132         ret_ref |= 1;
22133 }
22134         return ret_ref;
22135 }
22136 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
22137         LDKHTLCUpdate arg_conv;
22138         arg_conv.inner = (void*)(arg & (~1));
22139         arg_conv.is_owned = false;
22140         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22141         uint32_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
22142         return ret_val;
22143 }
22144
22145 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
22146         LDKHTLCUpdate orig_conv;
22147         orig_conv.inner = (void*)(orig & (~1));
22148         orig_conv.is_owned = false;
22149         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22150         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22151         uint32_t ret_ref = 0;
22152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22155         ret_ref = (uintptr_t)ret_var.inner;
22156         if (ret_var.is_owned) {
22157                 ret_ref |= 1;
22158         }
22159         return ret_ref;
22160 }
22161
22162 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
22163         LDKHTLCUpdate obj_conv;
22164         obj_conv.inner = (void*)(obj & (~1));
22165         obj_conv.is_owned = false;
22166         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22167         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22168         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22169         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22170         CVec_u8Z_free(ret_var);
22171         return ret_arr;
22172 }
22173
22174 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22175         LDKu8slice ser_ref;
22176         ser_ref.datalen = ser->arr_len;
22177         ser_ref.data = ser->elems /* XXX ser leaks */;
22178         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22179         *ret_conv = HTLCUpdate_read(ser_ref);
22180         return (uint32_t)ret_conv;
22181 }
22182
22183 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22184         if ((this_ptr & 1) != 0) return;
22185         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22186         CHECK_ACCESS(this_ptr_ptr);
22187         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22188         FREE((void*)this_ptr);
22189         Balance_free(this_ptr_conv);
22190 }
22191
22192 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22193         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22194         *ret_copy = Balance_clone(arg);
22195 uint32_t ret_ref = (uintptr_t)ret_copy;
22196         return ret_ref;
22197 }
22198 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22199         LDKBalance* arg_conv = (LDKBalance*)arg;
22200         uint32_t ret_val = Balance_clone_ptr(arg_conv);
22201         return ret_val;
22202 }
22203
22204 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22205         LDKBalance* orig_conv = (LDKBalance*)orig;
22206         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22207         *ret_copy = Balance_clone(orig_conv);
22208         uint32_t ret_ref = (uintptr_t)ret_copy;
22209         return ret_ref;
22210 }
22211
22212 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22213         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22214         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22215         uint32_t ret_ref = (uintptr_t)ret_copy;
22216         return ret_ref;
22217 }
22218
22219 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22220         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22221         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22222         uint32_t ret_ref = (uintptr_t)ret_copy;
22223         return ret_ref;
22224 }
22225
22226 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22227         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22228         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22229         uint32_t ret_ref = (uintptr_t)ret_copy;
22230         return ret_ref;
22231 }
22232
22233 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) {
22234         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22235         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22236         uint32_t ret_ref = (uintptr_t)ret_copy;
22237         return ret_ref;
22238 }
22239
22240 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22241         LDKBalance* a_conv = (LDKBalance*)a;
22242         LDKBalance* b_conv = (LDKBalance*)b;
22243         jboolean ret_val = Balance_eq(a_conv, b_conv);
22244         return ret_val;
22245 }
22246
22247 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22248         LDKChannelMonitor this_obj_conv;
22249         this_obj_conv.inner = (void*)(this_obj & (~1));
22250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22252         ChannelMonitor_free(this_obj_conv);
22253 }
22254
22255 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22256         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22257 uint32_t ret_ref = 0;
22258 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22259 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22261 ret_ref = (uintptr_t)ret_var.inner;
22262 if (ret_var.is_owned) {
22263         ret_ref |= 1;
22264 }
22265         return ret_ref;
22266 }
22267 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22268         LDKChannelMonitor arg_conv;
22269         arg_conv.inner = (void*)(arg & (~1));
22270         arg_conv.is_owned = false;
22271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22272         uint32_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
22273         return ret_val;
22274 }
22275
22276 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22277         LDKChannelMonitor orig_conv;
22278         orig_conv.inner = (void*)(orig & (~1));
22279         orig_conv.is_owned = false;
22280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22281         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22282         uint32_t ret_ref = 0;
22283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22286         ret_ref = (uintptr_t)ret_var.inner;
22287         if (ret_var.is_owned) {
22288                 ret_ref |= 1;
22289         }
22290         return ret_ref;
22291 }
22292
22293 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22294         LDKChannelMonitor obj_conv;
22295         obj_conv.inner = (void*)(obj & (~1));
22296         obj_conv.is_owned = false;
22297         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22298         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22299         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22300         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22301         CVec_u8Z_free(ret_var);
22302         return ret_arr;
22303 }
22304
22305 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) {
22306         LDKChannelMonitor this_arg_conv;
22307         this_arg_conv.inner = (void*)(this_arg & (~1));
22308         this_arg_conv.is_owned = false;
22309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22310         LDKChannelMonitorUpdate updates_conv;
22311         updates_conv.inner = (void*)(updates & (~1));
22312         updates_conv.is_owned = false;
22313         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22314         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22315         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22316         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22317         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22318         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22319         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22320         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22321         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22322         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22323         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22324         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22325         return (uint32_t)ret_conv;
22326 }
22327
22328 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22329         LDKChannelMonitor this_arg_conv;
22330         this_arg_conv.inner = (void*)(this_arg & (~1));
22331         this_arg_conv.is_owned = false;
22332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22333         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22334         return ret_val;
22335 }
22336
22337 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22338         LDKChannelMonitor this_arg_conv;
22339         this_arg_conv.inner = (void*)(this_arg & (~1));
22340         this_arg_conv.is_owned = false;
22341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22342         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22343         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22344         return ((uint32_t)ret_conv);
22345 }
22346
22347 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22348         LDKChannelMonitor this_arg_conv;
22349         this_arg_conv.inner = (void*)(this_arg & (~1));
22350         this_arg_conv.is_owned = false;
22351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22352         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22353         uint32_tArray ret_arr = NULL;
22354         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22355         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22356         for (size_t o = 0; o < ret_var.datalen; o++) {
22357                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22358                 *ret_conv_40_conv = ret_var.data[o];
22359                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22360         }
22361         
22362         FREE(ret_var.data);
22363         return ret_arr;
22364 }
22365
22366 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22367         LDKChannelMonitor this_arg_conv;
22368         this_arg_conv.inner = (void*)(this_arg & (~1));
22369         this_arg_conv.is_owned = false;
22370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22371         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22372         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22373         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22374         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22375 }
22376
22377 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) {
22378         LDKChannelMonitor this_arg_conv;
22379         this_arg_conv.inner = (void*)(this_arg & (~1));
22380         this_arg_conv.is_owned = false;
22381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22382         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22383         uint32_tArray ret_arr = NULL;
22384         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22385         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22386         for (size_t o = 0; o < ret_var.datalen; o++) {
22387                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22388                 *ret_conv_14_copy = ret_var.data[o];
22389                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22390                 ret_arr_ptr[o] = ret_conv_14_ref;
22391         }
22392         
22393         FREE(ret_var.data);
22394         return ret_arr;
22395 }
22396
22397 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22398         LDKChannelMonitor this_arg_conv;
22399         this_arg_conv.inner = (void*)(this_arg & (~1));
22400         this_arg_conv.is_owned = false;
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22402         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22403         uint32_tArray ret_arr = NULL;
22404         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22405         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22406         for (size_t h = 0; h < ret_var.datalen; h++) {
22407                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22408                 *ret_conv_7_copy = ret_var.data[h];
22409                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22410                 ret_arr_ptr[h] = ret_conv_7_ref;
22411         }
22412         
22413         FREE(ret_var.data);
22414         return ret_arr;
22415 }
22416
22417 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) {
22418         LDKChannelMonitor this_arg_conv;
22419         this_arg_conv.inner = (void*)(this_arg & (~1));
22420         this_arg_conv.is_owned = false;
22421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22422         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22423         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22424         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22425         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22426         ptrArray ret_arr = NULL;
22427         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22428         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22429         for (size_t m = 0; m < ret_var.datalen; m++) {
22430                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22431                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22432                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22433                 Transaction_free(ret_conv_12_var);
22434                 ret_arr_ptr[m] = ret_conv_12_arr;
22435         }
22436         
22437         FREE(ret_var.data);
22438         return ret_arr;
22439 }
22440
22441 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) {
22442         LDKChannelMonitor this_arg_conv;
22443         this_arg_conv.inner = (void*)(this_arg & (~1));
22444         this_arg_conv.is_owned = false;
22445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22446         unsigned char header_arr[80];
22447         CHECK(header->arr_len == 80);
22448         memcpy(header_arr, header->elems, 80); FREE(header);
22449         unsigned char (*header_ref)[80] = &header_arr;
22450         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22451         txdata_constr.datalen = txdata->arr_len;
22452         if (txdata_constr.datalen > 0)
22453                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22454         else
22455                 txdata_constr.data = NULL;
22456         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22457         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22458                 uint32_t txdata_conv_28 = txdata_vals[c];
22459                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22460                 CHECK_ACCESS(txdata_conv_28_ptr);
22461                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22462                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22463                 txdata_constr.data[c] = txdata_conv_28_conv;
22464         }
22465         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22466         CHECK_ACCESS(broadcaster_ptr);
22467         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22468         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22469                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22470                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22471         }
22472         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22473         CHECK_ACCESS(fee_estimator_ptr);
22474         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22475         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22477                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22478         }
22479         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22480         CHECK_ACCESS(logger_ptr);
22481         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22482         if (logger_conv.free == LDKLogger_JCalls_free) {
22483                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22484                 LDKLogger_JCalls_cloned(&logger_conv);
22485         }
22486         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);
22487         uint32_tArray ret_arr = NULL;
22488         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22489         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22490         for (size_t n = 0; n < ret_var.datalen; n++) {
22491                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22492                 *ret_conv_39_conv = ret_var.data[n];
22493                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22494         }
22495         
22496         FREE(ret_var.data);
22497         return ret_arr;
22498 }
22499
22500 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) {
22501         LDKChannelMonitor this_arg_conv;
22502         this_arg_conv.inner = (void*)(this_arg & (~1));
22503         this_arg_conv.is_owned = false;
22504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22505         unsigned char header_arr[80];
22506         CHECK(header->arr_len == 80);
22507         memcpy(header_arr, header->elems, 80); FREE(header);
22508         unsigned char (*header_ref)[80] = &header_arr;
22509         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22510         CHECK_ACCESS(broadcaster_ptr);
22511         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22512         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22514                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22515         }
22516         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22517         CHECK_ACCESS(fee_estimator_ptr);
22518         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22519         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22521                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22522         }
22523         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22524         CHECK_ACCESS(logger_ptr);
22525         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22526         if (logger_conv.free == LDKLogger_JCalls_free) {
22527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22528                 LDKLogger_JCalls_cloned(&logger_conv);
22529         }
22530         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22531 }
22532
22533 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) {
22534         LDKChannelMonitor this_arg_conv;
22535         this_arg_conv.inner = (void*)(this_arg & (~1));
22536         this_arg_conv.is_owned = false;
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22538         unsigned char header_arr[80];
22539         CHECK(header->arr_len == 80);
22540         memcpy(header_arr, header->elems, 80); FREE(header);
22541         unsigned char (*header_ref)[80] = &header_arr;
22542         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22543         txdata_constr.datalen = txdata->arr_len;
22544         if (txdata_constr.datalen > 0)
22545                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22546         else
22547                 txdata_constr.data = NULL;
22548         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22549         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22550                 uint32_t txdata_conv_28 = txdata_vals[c];
22551                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22552                 CHECK_ACCESS(txdata_conv_28_ptr);
22553                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22554                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22555                 txdata_constr.data[c] = txdata_conv_28_conv;
22556         }
22557         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22558         CHECK_ACCESS(broadcaster_ptr);
22559         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22560         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22561                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22562                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22563         }
22564         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22565         CHECK_ACCESS(fee_estimator_ptr);
22566         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22567         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22568                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22569                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22570         }
22571         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22572         CHECK_ACCESS(logger_ptr);
22573         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22574         if (logger_conv.free == LDKLogger_JCalls_free) {
22575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22576                 LDKLogger_JCalls_cloned(&logger_conv);
22577         }
22578         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);
22579         uint32_tArray ret_arr = NULL;
22580         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22581         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22582         for (size_t n = 0; n < ret_var.datalen; n++) {
22583                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22584                 *ret_conv_39_conv = ret_var.data[n];
22585                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22586         }
22587         
22588         FREE(ret_var.data);
22589         return ret_arr;
22590 }
22591
22592 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) {
22593         LDKChannelMonitor this_arg_conv;
22594         this_arg_conv.inner = (void*)(this_arg & (~1));
22595         this_arg_conv.is_owned = false;
22596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22597         unsigned char txid_arr[32];
22598         CHECK(txid->arr_len == 32);
22599         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22600         unsigned char (*txid_ref)[32] = &txid_arr;
22601         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22602         CHECK_ACCESS(broadcaster_ptr);
22603         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22604         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22606                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22607         }
22608         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22609         CHECK_ACCESS(fee_estimator_ptr);
22610         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22611         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22613                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22614         }
22615         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22616         CHECK_ACCESS(logger_ptr);
22617         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22618         if (logger_conv.free == LDKLogger_JCalls_free) {
22619                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22620                 LDKLogger_JCalls_cloned(&logger_conv);
22621         }
22622         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22623 }
22624
22625 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) {
22626         LDKChannelMonitor this_arg_conv;
22627         this_arg_conv.inner = (void*)(this_arg & (~1));
22628         this_arg_conv.is_owned = false;
22629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22630         unsigned char header_arr[80];
22631         CHECK(header->arr_len == 80);
22632         memcpy(header_arr, header->elems, 80); FREE(header);
22633         unsigned char (*header_ref)[80] = &header_arr;
22634         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22635         CHECK_ACCESS(broadcaster_ptr);
22636         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22637         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22638                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22639                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22640         }
22641         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22642         CHECK_ACCESS(fee_estimator_ptr);
22643         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22644         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22645                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22646                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22647         }
22648         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22649         CHECK_ACCESS(logger_ptr);
22650         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22651         if (logger_conv.free == LDKLogger_JCalls_free) {
22652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22653                 LDKLogger_JCalls_cloned(&logger_conv);
22654         }
22655         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22656         uint32_tArray ret_arr = NULL;
22657         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22658         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22659         for (size_t n = 0; n < ret_var.datalen; n++) {
22660                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22661                 *ret_conv_39_conv = ret_var.data[n];
22662                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22663         }
22664         
22665         FREE(ret_var.data);
22666         return ret_arr;
22667 }
22668
22669 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22670         LDKChannelMonitor this_arg_conv;
22671         this_arg_conv.inner = (void*)(this_arg & (~1));
22672         this_arg_conv.is_owned = false;
22673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22674         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22675         ptrArray ret_arr = NULL;
22676         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22677         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22678         for (size_t m = 0; m < ret_var.datalen; m++) {
22679                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22680                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22681                 ret_arr_ptr[m] = ret_conv_12_arr;
22682         }
22683         
22684         FREE(ret_var.data);
22685         return ret_arr;
22686 }
22687
22688 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22689         LDKChannelMonitor this_arg_conv;
22690         this_arg_conv.inner = (void*)(this_arg & (~1));
22691         this_arg_conv.is_owned = false;
22692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22693         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22694         uint32_t ret_ref = 0;
22695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22698         ret_ref = (uintptr_t)ret_var.inner;
22699         if (ret_var.is_owned) {
22700                 ret_ref |= 1;
22701         }
22702         return ret_ref;
22703 }
22704
22705 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22706         LDKChannelMonitor this_arg_conv;
22707         this_arg_conv.inner = (void*)(this_arg & (~1));
22708         this_arg_conv.is_owned = false;
22709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22710         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22711         uint32_tArray ret_arr = NULL;
22712         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22713         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22714         for (size_t j = 0; j < ret_var.datalen; j++) {
22715                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22716                 *ret_conv_9_copy = ret_var.data[j];
22717                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22718                 ret_arr_ptr[j] = ret_conv_9_ref;
22719         }
22720         
22721         FREE(ret_var.data);
22722         return ret_arr;
22723 }
22724
22725 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22726         LDKu8slice ser_ref;
22727         ser_ref.datalen = ser->arr_len;
22728         ser_ref.data = ser->elems /* XXX ser leaks */;
22729         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22730         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22731         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22732         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22733         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22734         return (uint32_t)ret_conv;
22735 }
22736
22737 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22738         LDKOutPoint this_obj_conv;
22739         this_obj_conv.inner = (void*)(this_obj & (~1));
22740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22742         OutPoint_free(this_obj_conv);
22743 }
22744
22745 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22746         LDKOutPoint this_ptr_conv;
22747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22748         this_ptr_conv.is_owned = false;
22749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22750         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22751         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22752         return ret_arr;
22753 }
22754
22755 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22756         LDKOutPoint this_ptr_conv;
22757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22758         this_ptr_conv.is_owned = false;
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22760         LDKThirtyTwoBytes val_ref;
22761         CHECK(val->arr_len == 32);
22762         memcpy(val_ref.data, val->elems, 32); FREE(val);
22763         OutPoint_set_txid(&this_ptr_conv, val_ref);
22764 }
22765
22766 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22767         LDKOutPoint this_ptr_conv;
22768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22769         this_ptr_conv.is_owned = false;
22770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22771         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22772         return ret_val;
22773 }
22774
22775 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22776         LDKOutPoint this_ptr_conv;
22777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22778         this_ptr_conv.is_owned = false;
22779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22780         OutPoint_set_index(&this_ptr_conv, val);
22781 }
22782
22783 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22784         LDKThirtyTwoBytes txid_arg_ref;
22785         CHECK(txid_arg->arr_len == 32);
22786         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22787         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22788         uint32_t ret_ref = 0;
22789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22792         ret_ref = (uintptr_t)ret_var.inner;
22793         if (ret_var.is_owned) {
22794                 ret_ref |= 1;
22795         }
22796         return ret_ref;
22797 }
22798
22799 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22800         LDKOutPoint ret_var = OutPoint_clone(arg);
22801 uint32_t ret_ref = 0;
22802 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22803 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22804 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22805 ret_ref = (uintptr_t)ret_var.inner;
22806 if (ret_var.is_owned) {
22807         ret_ref |= 1;
22808 }
22809         return ret_ref;
22810 }
22811 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22812         LDKOutPoint arg_conv;
22813         arg_conv.inner = (void*)(arg & (~1));
22814         arg_conv.is_owned = false;
22815         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22816         uint32_t ret_val = OutPoint_clone_ptr(&arg_conv);
22817         return ret_val;
22818 }
22819
22820 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22821         LDKOutPoint orig_conv;
22822         orig_conv.inner = (void*)(orig & (~1));
22823         orig_conv.is_owned = false;
22824         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22825         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22826         uint32_t ret_ref = 0;
22827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22830         ret_ref = (uintptr_t)ret_var.inner;
22831         if (ret_var.is_owned) {
22832                 ret_ref |= 1;
22833         }
22834         return ret_ref;
22835 }
22836
22837 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22838         LDKOutPoint a_conv;
22839         a_conv.inner = (void*)(a & (~1));
22840         a_conv.is_owned = false;
22841         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22842         LDKOutPoint b_conv;
22843         b_conv.inner = (void*)(b & (~1));
22844         b_conv.is_owned = false;
22845         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22846         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22847         return ret_val;
22848 }
22849
22850 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22851         LDKOutPoint o_conv;
22852         o_conv.inner = (void*)(o & (~1));
22853         o_conv.is_owned = false;
22854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22855         int64_t ret_val = OutPoint_hash(&o_conv);
22856         return ret_val;
22857 }
22858
22859 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22860         LDKOutPoint this_arg_conv;
22861         this_arg_conv.inner = (void*)(this_arg & (~1));
22862         this_arg_conv.is_owned = false;
22863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22864         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22865         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22866         return ret_arr;
22867 }
22868
22869 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22870         LDKOutPoint obj_conv;
22871         obj_conv.inner = (void*)(obj & (~1));
22872         obj_conv.is_owned = false;
22873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22874         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22875         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22876         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22877         CVec_u8Z_free(ret_var);
22878         return ret_arr;
22879 }
22880
22881 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22882         LDKu8slice ser_ref;
22883         ser_ref.datalen = ser->arr_len;
22884         ser_ref.data = ser->elems /* XXX ser leaks */;
22885         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22886         *ret_conv = OutPoint_read(ser_ref);
22887         return (uint32_t)ret_conv;
22888 }
22889
22890 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22891         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22892         this_obj_conv.inner = (void*)(this_obj & (~1));
22893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22895         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22896 }
22897
22898 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22899         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22901         this_ptr_conv.is_owned = false;
22902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22903         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22904         uint32_t ret_ref = 0;
22905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22908         ret_ref = (uintptr_t)ret_var.inner;
22909         if (ret_var.is_owned) {
22910                 ret_ref |= 1;
22911         }
22912         return ret_ref;
22913 }
22914
22915 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22916         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22918         this_ptr_conv.is_owned = false;
22919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22920         LDKOutPoint val_conv;
22921         val_conv.inner = (void*)(val & (~1));
22922         val_conv.is_owned = (val & 1) || (val == 0);
22923         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22924         val_conv = OutPoint_clone(&val_conv);
22925         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22926 }
22927
22928 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22929         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22931         this_ptr_conv.is_owned = false;
22932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22933         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22934         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22935         return ret_arr;
22936 }
22937
22938 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22939         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22941         this_ptr_conv.is_owned = false;
22942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22943         LDKPublicKey val_ref;
22944         CHECK(val->arr_len == 33);
22945         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22946         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22947 }
22948
22949 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
22950         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22952         this_ptr_conv.is_owned = false;
22953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22954         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22955         return ret_val;
22956 }
22957
22958 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22959         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22961         this_ptr_conv.is_owned = false;
22962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22963         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22964 }
22965
22966 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22967         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22969         this_ptr_conv.is_owned = false;
22970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22971         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22972         CHECK_ACCESS(val_ptr);
22973         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22974         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22975         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22976 }
22977
22978 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
22979         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22981         this_ptr_conv.is_owned = false;
22982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22983         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22984         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
22985         return ret_arr;
22986 }
22987
22988 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
22989         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22991         this_ptr_conv.is_owned = false;
22992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22993         LDKPublicKey val_ref;
22994         CHECK(val->arr_len == 33);
22995         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22996         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22997 }
22998
22999 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23000         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23002         this_ptr_conv.is_owned = false;
23003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23004         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23005         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23006         return ret_arr;
23007 }
23008
23009 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23010         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23012         this_ptr_conv.is_owned = false;
23013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23014         LDKThirtyTwoBytes val_ref;
23015         CHECK(val->arr_len == 32);
23016         memcpy(val_ref.data, val->elems, 32); FREE(val);
23017         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23018 }
23019
23020 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23021         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23023         this_ptr_conv.is_owned = false;
23024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23025         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23026         return ret_val;
23027 }
23028
23029 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23030         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23032         this_ptr_conv.is_owned = false;
23033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23034         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23035 }
23036
23037 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) {
23038         LDKOutPoint outpoint_arg_conv;
23039         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23040         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23041         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23042         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23043         LDKPublicKey per_commitment_point_arg_ref;
23044         CHECK(per_commitment_point_arg->arr_len == 33);
23045         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
23046         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23047         CHECK_ACCESS(output_arg_ptr);
23048         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23049         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23050         LDKPublicKey revocation_pubkey_arg_ref;
23051         CHECK(revocation_pubkey_arg->arr_len == 33);
23052         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
23053         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23054         CHECK(channel_keys_id_arg->arr_len == 32);
23055         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23056         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);
23057         uint32_t ret_ref = 0;
23058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23061         ret_ref = (uintptr_t)ret_var.inner;
23062         if (ret_var.is_owned) {
23063                 ret_ref |= 1;
23064         }
23065         return ret_ref;
23066 }
23067
23068 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23069         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23070 uint32_t ret_ref = 0;
23071 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23072 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23073 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23074 ret_ref = (uintptr_t)ret_var.inner;
23075 if (ret_var.is_owned) {
23076         ret_ref |= 1;
23077 }
23078         return ret_ref;
23079 }
23080 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23081         LDKDelayedPaymentOutputDescriptor arg_conv;
23082         arg_conv.inner = (void*)(arg & (~1));
23083         arg_conv.is_owned = false;
23084         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23085         uint32_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23086         return ret_val;
23087 }
23088
23089 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
23090         LDKDelayedPaymentOutputDescriptor orig_conv;
23091         orig_conv.inner = (void*)(orig & (~1));
23092         orig_conv.is_owned = false;
23093         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23094         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23095         uint32_t ret_ref = 0;
23096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23099         ret_ref = (uintptr_t)ret_var.inner;
23100         if (ret_var.is_owned) {
23101                 ret_ref |= 1;
23102         }
23103         return ret_ref;
23104 }
23105
23106 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
23107         LDKDelayedPaymentOutputDescriptor obj_conv;
23108         obj_conv.inner = (void*)(obj & (~1));
23109         obj_conv.is_owned = false;
23110         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23111         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23112         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23113         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23114         CVec_u8Z_free(ret_var);
23115         return ret_arr;
23116 }
23117
23118 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
23119         LDKu8slice ser_ref;
23120         ser_ref.datalen = ser->arr_len;
23121         ser_ref.data = ser->elems /* XXX ser leaks */;
23122         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23123         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23124         return (uint32_t)ret_conv;
23125 }
23126
23127 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
23128         LDKStaticPaymentOutputDescriptor this_obj_conv;
23129         this_obj_conv.inner = (void*)(this_obj & (~1));
23130         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23132         StaticPaymentOutputDescriptor_free(this_obj_conv);
23133 }
23134
23135 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23136         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23138         this_ptr_conv.is_owned = false;
23139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23140         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23141         uint32_t ret_ref = 0;
23142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23145         ret_ref = (uintptr_t)ret_var.inner;
23146         if (ret_var.is_owned) {
23147                 ret_ref |= 1;
23148         }
23149         return ret_ref;
23150 }
23151
23152 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23153         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23155         this_ptr_conv.is_owned = false;
23156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23157         LDKOutPoint val_conv;
23158         val_conv.inner = (void*)(val & (~1));
23159         val_conv.is_owned = (val & 1) || (val == 0);
23160         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23161         val_conv = OutPoint_clone(&val_conv);
23162         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23163 }
23164
23165 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23166         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23168         this_ptr_conv.is_owned = false;
23169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23170         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23171         CHECK_ACCESS(val_ptr);
23172         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23173         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23174         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23175 }
23176
23177 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23178         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23180         this_ptr_conv.is_owned = false;
23181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23182         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23183         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23184         return ret_arr;
23185 }
23186
23187 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23188         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23190         this_ptr_conv.is_owned = false;
23191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23192         LDKThirtyTwoBytes val_ref;
23193         CHECK(val->arr_len == 32);
23194         memcpy(val_ref.data, val->elems, 32); FREE(val);
23195         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23196 }
23197
23198 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23199         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23201         this_ptr_conv.is_owned = false;
23202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23203         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23204         return ret_val;
23205 }
23206
23207 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23208         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23210         this_ptr_conv.is_owned = false;
23211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23212         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23213 }
23214
23215 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) {
23216         LDKOutPoint outpoint_arg_conv;
23217         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23218         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23220         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23221         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23222         CHECK_ACCESS(output_arg_ptr);
23223         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23224         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23225         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23226         CHECK(channel_keys_id_arg->arr_len == 32);
23227         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23228         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23229         uint32_t ret_ref = 0;
23230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23233         ret_ref = (uintptr_t)ret_var.inner;
23234         if (ret_var.is_owned) {
23235                 ret_ref |= 1;
23236         }
23237         return ret_ref;
23238 }
23239
23240 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23241         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23242 uint32_t ret_ref = 0;
23243 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23244 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23245 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23246 ret_ref = (uintptr_t)ret_var.inner;
23247 if (ret_var.is_owned) {
23248         ret_ref |= 1;
23249 }
23250         return ret_ref;
23251 }
23252 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23253         LDKStaticPaymentOutputDescriptor arg_conv;
23254         arg_conv.inner = (void*)(arg & (~1));
23255         arg_conv.is_owned = false;
23256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23257         uint32_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23258         return ret_val;
23259 }
23260
23261 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23262         LDKStaticPaymentOutputDescriptor orig_conv;
23263         orig_conv.inner = (void*)(orig & (~1));
23264         orig_conv.is_owned = false;
23265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23266         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23267         uint32_t ret_ref = 0;
23268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23271         ret_ref = (uintptr_t)ret_var.inner;
23272         if (ret_var.is_owned) {
23273                 ret_ref |= 1;
23274         }
23275         return ret_ref;
23276 }
23277
23278 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23279         LDKStaticPaymentOutputDescriptor obj_conv;
23280         obj_conv.inner = (void*)(obj & (~1));
23281         obj_conv.is_owned = false;
23282         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23283         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23284         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23285         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23286         CVec_u8Z_free(ret_var);
23287         return ret_arr;
23288 }
23289
23290 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23291         LDKu8slice ser_ref;
23292         ser_ref.datalen = ser->arr_len;
23293         ser_ref.data = ser->elems /* XXX ser leaks */;
23294         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23295         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23296         return (uint32_t)ret_conv;
23297 }
23298
23299 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23300         if ((this_ptr & 1) != 0) return;
23301         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23302         CHECK_ACCESS(this_ptr_ptr);
23303         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23304         FREE((void*)this_ptr);
23305         SpendableOutputDescriptor_free(this_ptr_conv);
23306 }
23307
23308 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23309         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23310         *ret_copy = SpendableOutputDescriptor_clone(arg);
23311 uint32_t ret_ref = (uintptr_t)ret_copy;
23312         return ret_ref;
23313 }
23314 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23315         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23316         uint32_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23317         return ret_val;
23318 }
23319
23320 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23321         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23322         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23323         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23324         uint32_t ret_ref = (uintptr_t)ret_copy;
23325         return ret_ref;
23326 }
23327
23328 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
23329         LDKOutPoint outpoint_conv;
23330         outpoint_conv.inner = (void*)(outpoint & (~1));
23331         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23332         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23333         outpoint_conv = OutPoint_clone(&outpoint_conv);
23334         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
23335         CHECK_ACCESS(output_ptr);
23336         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23337         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
23338         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23339         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23340         uint32_t ret_ref = (uintptr_t)ret_copy;
23341         return ret_ref;
23342 }
23343
23344 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
23345         LDKDelayedPaymentOutputDescriptor a_conv;
23346         a_conv.inner = (void*)(a & (~1));
23347         a_conv.is_owned = (a & 1) || (a == 0);
23348         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23349         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23350         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23351         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23352         uint32_t ret_ref = (uintptr_t)ret_copy;
23353         return ret_ref;
23354 }
23355
23356 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
23357         LDKStaticPaymentOutputDescriptor a_conv;
23358         a_conv.inner = (void*)(a & (~1));
23359         a_conv.is_owned = (a & 1) || (a == 0);
23360         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23361         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23362         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23363         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23364         uint32_t ret_ref = (uintptr_t)ret_copy;
23365         return ret_ref;
23366 }
23367
23368 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
23369         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23370         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23371         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23372         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23373         CVec_u8Z_free(ret_var);
23374         return ret_arr;
23375 }
23376
23377 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23378         LDKu8slice ser_ref;
23379         ser_ref.datalen = ser->arr_len;
23380         ser_ref.data = ser->elems /* XXX ser leaks */;
23381         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23382         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23383         return (uint32_t)ret_conv;
23384 }
23385
23386 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23387         if ((this_ptr & 1) != 0) return;
23388         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23389         CHECK_ACCESS(this_ptr_ptr);
23390         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23391         FREE((void*)this_ptr);
23392         BaseSign_free(this_ptr_conv);
23393 }
23394
23395 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23396         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23397         *ret_ret = Sign_clone(arg);
23398         return (uint32_t)ret_ret;
23399 }
23400 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23401         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23402         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23403         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23404         uint32_t ret_val = Sign_clone_ptr(arg_conv);
23405         return ret_val;
23406 }
23407
23408 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23409         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23410         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23411         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23412         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23413         *ret_ret = Sign_clone(orig_conv);
23414         return (uint32_t)ret_ret;
23415 }
23416
23417 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23418         if ((this_ptr & 1) != 0) return;
23419         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23420         CHECK_ACCESS(this_ptr_ptr);
23421         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23422         FREE((void*)this_ptr);
23423         Sign_free(this_ptr_conv);
23424 }
23425
23426 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23427         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23428         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23429         return ret_conv;
23430 }
23431
23432 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23433         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23434         return ret_conv;
23435 }
23436
23437 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23438         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23439         return ret_conv;
23440 }
23441
23442 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23443         if ((this_ptr & 1) != 0) return;
23444         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23445         CHECK_ACCESS(this_ptr_ptr);
23446         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23447         FREE((void*)this_ptr);
23448         KeysInterface_free(this_ptr_conv);
23449 }
23450
23451 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23452         LDKInMemorySigner this_obj_conv;
23453         this_obj_conv.inner = (void*)(this_obj & (~1));
23454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23456         InMemorySigner_free(this_obj_conv);
23457 }
23458
23459 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23460         LDKInMemorySigner this_ptr_conv;
23461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23462         this_ptr_conv.is_owned = false;
23463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23464         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23465         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23466         return ret_arr;
23467 }
23468
23469 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23470         LDKInMemorySigner this_ptr_conv;
23471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23472         this_ptr_conv.is_owned = false;
23473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23474         LDKSecretKey val_ref;
23475         CHECK(val->arr_len == 32);
23476         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23477         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23478 }
23479
23480 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23481         LDKInMemorySigner this_ptr_conv;
23482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23483         this_ptr_conv.is_owned = false;
23484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23485         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23486         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23487         return ret_arr;
23488 }
23489
23490 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23491         LDKInMemorySigner this_ptr_conv;
23492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23493         this_ptr_conv.is_owned = false;
23494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23495         LDKSecretKey val_ref;
23496         CHECK(val->arr_len == 32);
23497         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23498         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23499 }
23500
23501 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23502         LDKInMemorySigner this_ptr_conv;
23503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23504         this_ptr_conv.is_owned = false;
23505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23506         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23507         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23508         return ret_arr;
23509 }
23510
23511 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23512         LDKInMemorySigner this_ptr_conv;
23513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23514         this_ptr_conv.is_owned = false;
23515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23516         LDKSecretKey val_ref;
23517         CHECK(val->arr_len == 32);
23518         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23519         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23520 }
23521
23522 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23523         LDKInMemorySigner this_ptr_conv;
23524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23525         this_ptr_conv.is_owned = false;
23526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23527         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23528         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23529         return ret_arr;
23530 }
23531
23532 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) {
23533         LDKInMemorySigner this_ptr_conv;
23534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23535         this_ptr_conv.is_owned = false;
23536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23537         LDKSecretKey val_ref;
23538         CHECK(val->arr_len == 32);
23539         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23540         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23541 }
23542
23543 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23544         LDKInMemorySigner this_ptr_conv;
23545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23546         this_ptr_conv.is_owned = false;
23547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23548         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23549         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23550         return ret_arr;
23551 }
23552
23553 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23554         LDKInMemorySigner this_ptr_conv;
23555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23556         this_ptr_conv.is_owned = false;
23557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23558         LDKSecretKey val_ref;
23559         CHECK(val->arr_len == 32);
23560         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23561         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23562 }
23563
23564 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23565         LDKInMemorySigner this_ptr_conv;
23566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23567         this_ptr_conv.is_owned = false;
23568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23569         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23570         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23571         return ret_arr;
23572 }
23573
23574 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23575         LDKInMemorySigner this_ptr_conv;
23576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23577         this_ptr_conv.is_owned = false;
23578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23579         LDKThirtyTwoBytes val_ref;
23580         CHECK(val->arr_len == 32);
23581         memcpy(val_ref.data, val->elems, 32); FREE(val);
23582         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23583 }
23584
23585 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23586         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23587 uint32_t ret_ref = 0;
23588 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23589 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23590 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23591 ret_ref = (uintptr_t)ret_var.inner;
23592 if (ret_var.is_owned) {
23593         ret_ref |= 1;
23594 }
23595         return ret_ref;
23596 }
23597 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23598         LDKInMemorySigner arg_conv;
23599         arg_conv.inner = (void*)(arg & (~1));
23600         arg_conv.is_owned = false;
23601         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23602         uint32_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23603         return ret_val;
23604 }
23605
23606 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23607         LDKInMemorySigner orig_conv;
23608         orig_conv.inner = (void*)(orig & (~1));
23609         orig_conv.is_owned = false;
23610         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23611         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23612         uint32_t ret_ref = 0;
23613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23616         ret_ref = (uintptr_t)ret_var.inner;
23617         if (ret_var.is_owned) {
23618                 ret_ref |= 1;
23619         }
23620         return ret_ref;
23621 }
23622
23623 uint32_t  __attribute__((export_name("TS_InMemorySigner_new"))) TS_InMemorySigner_new(int8_tArray node_secret, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
23624         LDKSecretKey node_secret_ref;
23625         CHECK(node_secret->arr_len == 32);
23626         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23627         LDKSecretKey funding_key_ref;
23628         CHECK(funding_key->arr_len == 32);
23629         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23630         LDKSecretKey revocation_base_key_ref;
23631         CHECK(revocation_base_key->arr_len == 32);
23632         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23633         LDKSecretKey payment_key_ref;
23634         CHECK(payment_key->arr_len == 32);
23635         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23636         LDKSecretKey delayed_payment_base_key_ref;
23637         CHECK(delayed_payment_base_key->arr_len == 32);
23638         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23639         LDKSecretKey htlc_base_key_ref;
23640         CHECK(htlc_base_key->arr_len == 32);
23641         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23642         LDKThirtyTwoBytes commitment_seed_ref;
23643         CHECK(commitment_seed->arr_len == 32);
23644         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23645         LDKThirtyTwoBytes channel_keys_id_ref;
23646         CHECK(channel_keys_id->arr_len == 32);
23647         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23648         LDKInMemorySigner ret_var = InMemorySigner_new(node_secret_ref, funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
23649         uint32_t ret_ref = 0;
23650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23653         ret_ref = (uintptr_t)ret_var.inner;
23654         if (ret_var.is_owned) {
23655                 ret_ref |= 1;
23656         }
23657         return ret_ref;
23658 }
23659
23660 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23661         LDKInMemorySigner this_arg_conv;
23662         this_arg_conv.inner = (void*)(this_arg & (~1));
23663         this_arg_conv.is_owned = false;
23664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23665         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23666         uint32_t ret_ref = 0;
23667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23670         ret_ref = (uintptr_t)ret_var.inner;
23671         if (ret_var.is_owned) {
23672                 ret_ref |= 1;
23673         }
23674         return ret_ref;
23675 }
23676
23677 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23678         LDKInMemorySigner this_arg_conv;
23679         this_arg_conv.inner = (void*)(this_arg & (~1));
23680         this_arg_conv.is_owned = false;
23681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23682         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23683         return ret_val;
23684 }
23685
23686 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23687         LDKInMemorySigner this_arg_conv;
23688         this_arg_conv.inner = (void*)(this_arg & (~1));
23689         this_arg_conv.is_owned = false;
23690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23691         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23692         return ret_val;
23693 }
23694
23695 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23696         LDKInMemorySigner this_arg_conv;
23697         this_arg_conv.inner = (void*)(this_arg & (~1));
23698         this_arg_conv.is_owned = false;
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23700         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23701         return ret_val;
23702 }
23703
23704 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23705         LDKInMemorySigner this_arg_conv;
23706         this_arg_conv.inner = (void*)(this_arg & (~1));
23707         this_arg_conv.is_owned = false;
23708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23709         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23710         uint32_t ret_ref = 0;
23711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23714         ret_ref = (uintptr_t)ret_var.inner;
23715         if (ret_var.is_owned) {
23716                 ret_ref |= 1;
23717         }
23718         return ret_ref;
23719 }
23720
23721 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23722         LDKInMemorySigner this_arg_conv;
23723         this_arg_conv.inner = (void*)(this_arg & (~1));
23724         this_arg_conv.is_owned = false;
23725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23726         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23727         uint32_t ret_ref = 0;
23728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23731         ret_ref = (uintptr_t)ret_var.inner;
23732         if (ret_var.is_owned) {
23733                 ret_ref |= 1;
23734         }
23735         return ret_ref;
23736 }
23737
23738 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23739         LDKInMemorySigner this_arg_conv;
23740         this_arg_conv.inner = (void*)(this_arg & (~1));
23741         this_arg_conv.is_owned = false;
23742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23743         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
23744         return ret_val;
23745 }
23746
23747 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_counterparty_payment_input"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
23748         LDKInMemorySigner this_arg_conv;
23749         this_arg_conv.inner = (void*)(this_arg & (~1));
23750         this_arg_conv.is_owned = false;
23751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23752         LDKTransaction spend_tx_ref;
23753         spend_tx_ref.datalen = spend_tx->arr_len;
23754         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23755         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23756         spend_tx_ref.data_is_owned = true;
23757         LDKStaticPaymentOutputDescriptor descriptor_conv;
23758         descriptor_conv.inner = (void*)(descriptor & (~1));
23759         descriptor_conv.is_owned = false;
23760         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23761         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23762         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23763         return (uint32_t)ret_conv;
23764 }
23765
23766 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_dynamic_p2wsh_input"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
23767         LDKInMemorySigner this_arg_conv;
23768         this_arg_conv.inner = (void*)(this_arg & (~1));
23769         this_arg_conv.is_owned = false;
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23771         LDKTransaction spend_tx_ref;
23772         spend_tx_ref.datalen = spend_tx->arr_len;
23773         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23774         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23775         spend_tx_ref.data_is_owned = true;
23776         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23777         descriptor_conv.inner = (void*)(descriptor & (~1));
23778         descriptor_conv.is_owned = false;
23779         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23780         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23781         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23782         return (uint32_t)ret_conv;
23783 }
23784
23785 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23786         LDKInMemorySigner this_arg_conv;
23787         this_arg_conv.inner = (void*)(this_arg & (~1));
23788         this_arg_conv.is_owned = false;
23789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23790         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23791         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23792         return (uint32_t)ret_ret;
23793 }
23794
23795 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23796         LDKInMemorySigner this_arg_conv;
23797         this_arg_conv.inner = (void*)(this_arg & (~1));
23798         this_arg_conv.is_owned = false;
23799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23800         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23801         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23802         return (uint32_t)ret_ret;
23803 }
23804
23805 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23806         LDKInMemorySigner obj_conv;
23807         obj_conv.inner = (void*)(obj & (~1));
23808         obj_conv.is_owned = false;
23809         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23810         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23811         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23812         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23813         CVec_u8Z_free(ret_var);
23814         return ret_arr;
23815 }
23816
23817 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23818         LDKu8slice ser_ref;
23819         ser_ref.datalen = ser->arr_len;
23820         ser_ref.data = ser->elems /* XXX ser leaks */;
23821         LDKSecretKey arg_ref;
23822         CHECK(arg->arr_len == 32);
23823         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23824         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23825         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23826         return (uint32_t)ret_conv;
23827 }
23828
23829 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23830         LDKKeysManager this_obj_conv;
23831         this_obj_conv.inner = (void*)(this_obj & (~1));
23832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23834         KeysManager_free(this_obj_conv);
23835 }
23836
23837 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23838         unsigned char seed_arr[32];
23839         CHECK(seed->arr_len == 32);
23840         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23841         unsigned char (*seed_ref)[32] = &seed_arr;
23842         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23843         uint32_t ret_ref = 0;
23844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23847         ret_ref = (uintptr_t)ret_var.inner;
23848         if (ret_var.is_owned) {
23849                 ret_ref |= 1;
23850         }
23851         return ret_ref;
23852 }
23853
23854 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) {
23855         LDKKeysManager this_arg_conv;
23856         this_arg_conv.inner = (void*)(this_arg & (~1));
23857         this_arg_conv.is_owned = false;
23858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23859         unsigned char params_arr[32];
23860         CHECK(params->arr_len == 32);
23861         memcpy(params_arr, params->elems, 32); FREE(params);
23862         unsigned char (*params_ref)[32] = &params_arr;
23863         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23864         uint32_t ret_ref = 0;
23865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23868         ret_ref = (uintptr_t)ret_var.inner;
23869         if (ret_var.is_owned) {
23870                 ret_ref |= 1;
23871         }
23872         return ret_ref;
23873 }
23874
23875 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) {
23876         LDKKeysManager this_arg_conv;
23877         this_arg_conv.inner = (void*)(this_arg & (~1));
23878         this_arg_conv.is_owned = false;
23879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23880         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23881         descriptors_constr.datalen = descriptors->arr_len;
23882         if (descriptors_constr.datalen > 0)
23883                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23884         else
23885                 descriptors_constr.data = NULL;
23886         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23887         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23888                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23889                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23890                 CHECK_ACCESS(descriptors_conv_27_ptr);
23891                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23892                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23893                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23894         }
23895         LDKCVec_TxOutZ outputs_constr;
23896         outputs_constr.datalen = outputs->arr_len;
23897         if (outputs_constr.datalen > 0)
23898                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23899         else
23900                 outputs_constr.data = NULL;
23901         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23902         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23903                 uint32_t outputs_conv_7 = outputs_vals[h];
23904                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23905                 CHECK_ACCESS(outputs_conv_7_ptr);
23906                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23907                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23908                 outputs_constr.data[h] = outputs_conv_7_conv;
23909         }
23910         LDKCVec_u8Z change_destination_script_ref;
23911         change_destination_script_ref.datalen = change_destination_script->arr_len;
23912         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23913         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23914         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23915         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23916         return (uint32_t)ret_conv;
23917 }
23918
23919 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23920         LDKKeysManager this_arg_conv;
23921         this_arg_conv.inner = (void*)(this_arg & (~1));
23922         this_arg_conv.is_owned = false;
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23924         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23925         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23926         return (uint32_t)ret_ret;
23927 }
23928
23929 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23930         LDKPhantomKeysManager this_obj_conv;
23931         this_obj_conv.inner = (void*)(this_obj & (~1));
23932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23934         PhantomKeysManager_free(this_obj_conv);
23935 }
23936
23937 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23938         LDKPhantomKeysManager this_arg_conv;
23939         this_arg_conv.inner = (void*)(this_arg & (~1));
23940         this_arg_conv.is_owned = false;
23941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23942         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23943         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
23944         return (uint32_t)ret_ret;
23945 }
23946
23947 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_new"))) TS_PhantomKeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
23948         unsigned char seed_arr[32];
23949         CHECK(seed->arr_len == 32);
23950         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23951         unsigned char (*seed_ref)[32] = &seed_arr;
23952         unsigned char cross_node_seed_arr[32];
23953         CHECK(cross_node_seed->arr_len == 32);
23954         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
23955         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
23956         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
23957         uint32_t ret_ref = 0;
23958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23961         ret_ref = (uintptr_t)ret_var.inner;
23962         if (ret_var.is_owned) {
23963                 ret_ref |= 1;
23964         }
23965         return ret_ref;
23966 }
23967
23968 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_spend_spendable_outputs"))) TS_PhantomKeysManager_spend_spendable_outputs(uint32_t this_arg, uint32_tArray descriptors, uint32_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
23969         LDKPhantomKeysManager this_arg_conv;
23970         this_arg_conv.inner = (void*)(this_arg & (~1));
23971         this_arg_conv.is_owned = false;
23972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23973         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23974         descriptors_constr.datalen = descriptors->arr_len;
23975         if (descriptors_constr.datalen > 0)
23976                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23977         else
23978                 descriptors_constr.data = NULL;
23979         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23980         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23981                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23982                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23983                 CHECK_ACCESS(descriptors_conv_27_ptr);
23984                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23985                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23986                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23987         }
23988         LDKCVec_TxOutZ outputs_constr;
23989         outputs_constr.datalen = outputs->arr_len;
23990         if (outputs_constr.datalen > 0)
23991                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23992         else
23993                 outputs_constr.data = NULL;
23994         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23995         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23996                 uint32_t outputs_conv_7 = outputs_vals[h];
23997                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23998                 CHECK_ACCESS(outputs_conv_7_ptr);
23999                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24000                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24001                 outputs_constr.data[h] = outputs_conv_7_conv;
24002         }
24003         LDKCVec_u8Z change_destination_script_ref;
24004         change_destination_script_ref.datalen = change_destination_script->arr_len;
24005         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24006         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24007         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24008         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24009         return (uint32_t)ret_conv;
24010 }
24011
24012 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_derive_channel_keys"))) TS_PhantomKeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
24013         LDKPhantomKeysManager this_arg_conv;
24014         this_arg_conv.inner = (void*)(this_arg & (~1));
24015         this_arg_conv.is_owned = false;
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24017         unsigned char params_arr[32];
24018         CHECK(params->arr_len == 32);
24019         memcpy(params_arr, params->elems, 32); FREE(params);
24020         unsigned char (*params_ref)[32] = &params_arr;
24021         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24022         uint32_t ret_ref = 0;
24023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24026         ret_ref = (uintptr_t)ret_var.inner;
24027         if (ret_var.is_owned) {
24028                 ret_ref |= 1;
24029         }
24030         return ret_ref;
24031 }
24032
24033 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
24034         LDKChannelManager this_obj_conv;
24035         this_obj_conv.inner = (void*)(this_obj & (~1));
24036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24038         ChannelManager_free(this_obj_conv);
24039 }
24040
24041 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
24042         LDKChainParameters this_obj_conv;
24043         this_obj_conv.inner = (void*)(this_obj & (~1));
24044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24046         ChainParameters_free(this_obj_conv);
24047 }
24048
24049 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
24050         LDKChainParameters this_ptr_conv;
24051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24052         this_ptr_conv.is_owned = false;
24053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24054         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
24055         return ret_conv;
24056 }
24057
24058 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
24059         LDKChainParameters this_ptr_conv;
24060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24061         this_ptr_conv.is_owned = false;
24062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24063         LDKNetwork val_conv = LDKNetwork_from_js(val);
24064         ChainParameters_set_network(&this_ptr_conv, val_conv);
24065 }
24066
24067 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
24068         LDKChainParameters this_ptr_conv;
24069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24070         this_ptr_conv.is_owned = false;
24071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24072         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24073         uint32_t ret_ref = 0;
24074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24077         ret_ref = (uintptr_t)ret_var.inner;
24078         if (ret_var.is_owned) {
24079                 ret_ref |= 1;
24080         }
24081         return ret_ref;
24082 }
24083
24084 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
24085         LDKChainParameters this_ptr_conv;
24086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24087         this_ptr_conv.is_owned = false;
24088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24089         LDKBestBlock val_conv;
24090         val_conv.inner = (void*)(val & (~1));
24091         val_conv.is_owned = (val & 1) || (val == 0);
24092         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24093         val_conv = BestBlock_clone(&val_conv);
24094         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24095 }
24096
24097 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
24098         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
24099         LDKBestBlock best_block_arg_conv;
24100         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24101         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24102         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24103         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24104         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24105         uint32_t ret_ref = 0;
24106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24109         ret_ref = (uintptr_t)ret_var.inner;
24110         if (ret_var.is_owned) {
24111                 ret_ref |= 1;
24112         }
24113         return ret_ref;
24114 }
24115
24116 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24117         LDKChainParameters ret_var = ChainParameters_clone(arg);
24118 uint32_t ret_ref = 0;
24119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24122 ret_ref = (uintptr_t)ret_var.inner;
24123 if (ret_var.is_owned) {
24124         ret_ref |= 1;
24125 }
24126         return ret_ref;
24127 }
24128 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
24129         LDKChainParameters arg_conv;
24130         arg_conv.inner = (void*)(arg & (~1));
24131         arg_conv.is_owned = false;
24132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24133         uint32_t ret_val = ChainParameters_clone_ptr(&arg_conv);
24134         return ret_val;
24135 }
24136
24137 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
24138         LDKChainParameters orig_conv;
24139         orig_conv.inner = (void*)(orig & (~1));
24140         orig_conv.is_owned = false;
24141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24142         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24143         uint32_t ret_ref = 0;
24144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24147         ret_ref = (uintptr_t)ret_var.inner;
24148         if (ret_var.is_owned) {
24149                 ret_ref |= 1;
24150         }
24151         return ret_ref;
24152 }
24153
24154 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
24155         LDKCounterpartyForwardingInfo this_obj_conv;
24156         this_obj_conv.inner = (void*)(this_obj & (~1));
24157         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24159         CounterpartyForwardingInfo_free(this_obj_conv);
24160 }
24161
24162 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
24163         LDKCounterpartyForwardingInfo this_ptr_conv;
24164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24165         this_ptr_conv.is_owned = false;
24166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24167         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24168         return ret_val;
24169 }
24170
24171 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
24172         LDKCounterpartyForwardingInfo this_ptr_conv;
24173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24174         this_ptr_conv.is_owned = false;
24175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24176         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24177 }
24178
24179 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
24180         LDKCounterpartyForwardingInfo this_ptr_conv;
24181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24182         this_ptr_conv.is_owned = false;
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24184         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24185         return ret_val;
24186 }
24187
24188 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
24189         LDKCounterpartyForwardingInfo this_ptr_conv;
24190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24191         this_ptr_conv.is_owned = false;
24192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24193         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24194 }
24195
24196 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24197         LDKCounterpartyForwardingInfo this_ptr_conv;
24198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24199         this_ptr_conv.is_owned = false;
24200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24201         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24202         return ret_val;
24203 }
24204
24205 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24206         LDKCounterpartyForwardingInfo this_ptr_conv;
24207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24208         this_ptr_conv.is_owned = false;
24209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24210         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24211 }
24212
24213 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) {
24214         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24215         uint32_t ret_ref = 0;
24216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24219         ret_ref = (uintptr_t)ret_var.inner;
24220         if (ret_var.is_owned) {
24221                 ret_ref |= 1;
24222         }
24223         return ret_ref;
24224 }
24225
24226 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24227         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24228 uint32_t ret_ref = 0;
24229 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24230 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24231 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24232 ret_ref = (uintptr_t)ret_var.inner;
24233 if (ret_var.is_owned) {
24234         ret_ref |= 1;
24235 }
24236         return ret_ref;
24237 }
24238 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24239         LDKCounterpartyForwardingInfo arg_conv;
24240         arg_conv.inner = (void*)(arg & (~1));
24241         arg_conv.is_owned = false;
24242         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24243         uint32_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24244         return ret_val;
24245 }
24246
24247 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24248         LDKCounterpartyForwardingInfo orig_conv;
24249         orig_conv.inner = (void*)(orig & (~1));
24250         orig_conv.is_owned = false;
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24252         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24253         uint32_t ret_ref = 0;
24254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24257         ret_ref = (uintptr_t)ret_var.inner;
24258         if (ret_var.is_owned) {
24259                 ret_ref |= 1;
24260         }
24261         return ret_ref;
24262 }
24263
24264 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24265         LDKChannelCounterparty this_obj_conv;
24266         this_obj_conv.inner = (void*)(this_obj & (~1));
24267         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24269         ChannelCounterparty_free(this_obj_conv);
24270 }
24271
24272 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24273         LDKChannelCounterparty this_ptr_conv;
24274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24275         this_ptr_conv.is_owned = false;
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24277         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24278         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24279         return ret_arr;
24280 }
24281
24282 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24283         LDKChannelCounterparty this_ptr_conv;
24284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24285         this_ptr_conv.is_owned = false;
24286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24287         LDKPublicKey val_ref;
24288         CHECK(val->arr_len == 33);
24289         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24290         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24291 }
24292
24293 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24294         LDKChannelCounterparty this_ptr_conv;
24295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24296         this_ptr_conv.is_owned = false;
24297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24298         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24299         uint32_t ret_ref = 0;
24300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24303         ret_ref = (uintptr_t)ret_var.inner;
24304         if (ret_var.is_owned) {
24305                 ret_ref |= 1;
24306         }
24307         return ret_ref;
24308 }
24309
24310 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24311         LDKChannelCounterparty this_ptr_conv;
24312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24313         this_ptr_conv.is_owned = false;
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24315         LDKInitFeatures val_conv;
24316         val_conv.inner = (void*)(val & (~1));
24317         val_conv.is_owned = (val & 1) || (val == 0);
24318         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24319         val_conv = InitFeatures_clone(&val_conv);
24320         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24321 }
24322
24323 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24324         LDKChannelCounterparty this_ptr_conv;
24325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24326         this_ptr_conv.is_owned = false;
24327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24328         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24329         return ret_val;
24330 }
24331
24332 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
24333         LDKChannelCounterparty this_ptr_conv;
24334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24335         this_ptr_conv.is_owned = false;
24336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24337         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24338 }
24339
24340 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
24341         LDKChannelCounterparty this_ptr_conv;
24342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24343         this_ptr_conv.is_owned = false;
24344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24345         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24346         uint32_t ret_ref = 0;
24347         if ((uintptr_t)ret_var.inner > 4096) {
24348                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24349                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24351                 ret_ref = (uintptr_t)ret_var.inner;
24352                 if (ret_var.is_owned) {
24353                         ret_ref |= 1;
24354                 }
24355         }
24356         return ret_ref;
24357 }
24358
24359 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
24360         LDKChannelCounterparty this_ptr_conv;
24361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24362         this_ptr_conv.is_owned = false;
24363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24364         LDKCounterpartyForwardingInfo val_conv;
24365         val_conv.inner = (void*)(val & (~1));
24366         val_conv.is_owned = (val & 1) || (val == 0);
24367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24368         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24369         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24370 }
24371
24372 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) {
24373         LDKPublicKey node_id_arg_ref;
24374         CHECK(node_id_arg->arr_len == 33);
24375         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24376         LDKInitFeatures features_arg_conv;
24377         features_arg_conv.inner = (void*)(features_arg & (~1));
24378         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24379         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24380         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24381         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24382         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24383         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24384         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24385         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24386         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24387         uint32_t ret_ref = 0;
24388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24391         ret_ref = (uintptr_t)ret_var.inner;
24392         if (ret_var.is_owned) {
24393                 ret_ref |= 1;
24394         }
24395         return ret_ref;
24396 }
24397
24398 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24399         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24400 uint32_t ret_ref = 0;
24401 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24402 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24403 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24404 ret_ref = (uintptr_t)ret_var.inner;
24405 if (ret_var.is_owned) {
24406         ret_ref |= 1;
24407 }
24408         return ret_ref;
24409 }
24410 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24411         LDKChannelCounterparty arg_conv;
24412         arg_conv.inner = (void*)(arg & (~1));
24413         arg_conv.is_owned = false;
24414         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24415         uint32_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24416         return ret_val;
24417 }
24418
24419 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24420         LDKChannelCounterparty orig_conv;
24421         orig_conv.inner = (void*)(orig & (~1));
24422         orig_conv.is_owned = false;
24423         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24424         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24425         uint32_t ret_ref = 0;
24426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24429         ret_ref = (uintptr_t)ret_var.inner;
24430         if (ret_var.is_owned) {
24431                 ret_ref |= 1;
24432         }
24433         return ret_ref;
24434 }
24435
24436 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24437         LDKChannelDetails this_obj_conv;
24438         this_obj_conv.inner = (void*)(this_obj & (~1));
24439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24441         ChannelDetails_free(this_obj_conv);
24442 }
24443
24444 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24445         LDKChannelDetails this_ptr_conv;
24446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24447         this_ptr_conv.is_owned = false;
24448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24449         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24450         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24451         return ret_arr;
24452 }
24453
24454 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24455         LDKChannelDetails this_ptr_conv;
24456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24457         this_ptr_conv.is_owned = false;
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24459         LDKThirtyTwoBytes val_ref;
24460         CHECK(val->arr_len == 32);
24461         memcpy(val_ref.data, val->elems, 32); FREE(val);
24462         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24463 }
24464
24465 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24466         LDKChannelDetails this_ptr_conv;
24467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24468         this_ptr_conv.is_owned = false;
24469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24470         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24471         uint32_t ret_ref = 0;
24472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24475         ret_ref = (uintptr_t)ret_var.inner;
24476         if (ret_var.is_owned) {
24477                 ret_ref |= 1;
24478         }
24479         return ret_ref;
24480 }
24481
24482 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24483         LDKChannelDetails this_ptr_conv;
24484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24485         this_ptr_conv.is_owned = false;
24486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24487         LDKChannelCounterparty val_conv;
24488         val_conv.inner = (void*)(val & (~1));
24489         val_conv.is_owned = (val & 1) || (val == 0);
24490         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24491         val_conv = ChannelCounterparty_clone(&val_conv);
24492         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24493 }
24494
24495 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24496         LDKChannelDetails 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         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24501         uint32_t ret_ref = 0;
24502         if ((uintptr_t)ret_var.inner > 4096) {
24503                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24504                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24506                 ret_ref = (uintptr_t)ret_var.inner;
24507                 if (ret_var.is_owned) {
24508                         ret_ref |= 1;
24509                 }
24510         }
24511         return ret_ref;
24512 }
24513
24514 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24515         LDKChannelDetails this_ptr_conv;
24516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24517         this_ptr_conv.is_owned = false;
24518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24519         LDKOutPoint val_conv;
24520         val_conv.inner = (void*)(val & (~1));
24521         val_conv.is_owned = (val & 1) || (val == 0);
24522         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24523         val_conv = OutPoint_clone(&val_conv);
24524         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24525 }
24526
24527 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
24528         LDKChannelDetails this_ptr_conv;
24529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24530         this_ptr_conv.is_owned = false;
24531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24532         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
24533         uint32_t ret_ref = 0;
24534         if ((uintptr_t)ret_var.inner > 4096) {
24535                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24536                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24538                 ret_ref = (uintptr_t)ret_var.inner;
24539                 if (ret_var.is_owned) {
24540                         ret_ref |= 1;
24541                 }
24542         }
24543         return ret_ref;
24544 }
24545
24546 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
24547         LDKChannelDetails this_ptr_conv;
24548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24549         this_ptr_conv.is_owned = false;
24550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24551         LDKChannelTypeFeatures val_conv;
24552         val_conv.inner = (void*)(val & (~1));
24553         val_conv.is_owned = (val & 1) || (val == 0);
24554         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24555         val_conv = ChannelTypeFeatures_clone(&val_conv);
24556         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
24557 }
24558
24559 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24560         LDKChannelDetails this_ptr_conv;
24561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24562         this_ptr_conv.is_owned = false;
24563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24564         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24565         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24566         uint32_t ret_ref = (uintptr_t)ret_copy;
24567         return ret_ref;
24568 }
24569
24570 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24571         LDKChannelDetails this_ptr_conv;
24572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24573         this_ptr_conv.is_owned = false;
24574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24575         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24576         CHECK_ACCESS(val_ptr);
24577         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24578         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24579         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24580 }
24581
24582 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
24583         LDKChannelDetails this_ptr_conv;
24584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24585         this_ptr_conv.is_owned = false;
24586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24587         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24588         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
24589         uint32_t ret_ref = (uintptr_t)ret_copy;
24590         return ret_ref;
24591 }
24592
24593 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
24594         LDKChannelDetails this_ptr_conv;
24595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24596         this_ptr_conv.is_owned = false;
24597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24598         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24599         CHECK_ACCESS(val_ptr);
24600         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24601         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24602         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
24603 }
24604
24605 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24606         LDKChannelDetails 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         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24611         return ret_val;
24612 }
24613
24614 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24615         LDKChannelDetails this_ptr_conv;
24616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24617         this_ptr_conv.is_owned = false;
24618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24619         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24620 }
24621
24622 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24623         LDKChannelDetails this_ptr_conv;
24624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24625         this_ptr_conv.is_owned = false;
24626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24627         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24628         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24629         uint32_t ret_ref = (uintptr_t)ret_copy;
24630         return ret_ref;
24631 }
24632
24633 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24634         LDKChannelDetails this_ptr_conv;
24635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24636         this_ptr_conv.is_owned = false;
24637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24638         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24639         CHECK_ACCESS(val_ptr);
24640         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24641         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24642         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24643 }
24644
24645 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
24646         LDKChannelDetails this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24651         return ret_val;
24652 }
24653
24654 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24655         LDKChannelDetails this_ptr_conv;
24656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24657         this_ptr_conv.is_owned = false;
24658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24659         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24660 }
24661
24662 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24663         LDKChannelDetails this_ptr_conv;
24664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24665         this_ptr_conv.is_owned = false;
24666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24667         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24668         return ret_val;
24669 }
24670
24671 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24672         LDKChannelDetails this_ptr_conv;
24673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24674         this_ptr_conv.is_owned = false;
24675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24676         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24677 }
24678
24679 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24680         LDKChannelDetails this_ptr_conv;
24681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24682         this_ptr_conv.is_owned = false;
24683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24684         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24685         return ret_val;
24686 }
24687
24688 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24689         LDKChannelDetails this_ptr_conv;
24690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24691         this_ptr_conv.is_owned = false;
24692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24693         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24694 }
24695
24696 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
24697         LDKChannelDetails this_ptr_conv;
24698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24699         this_ptr_conv.is_owned = false;
24700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24701         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24702         return ret_val;
24703 }
24704
24705 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24706         LDKChannelDetails this_ptr_conv;
24707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24708         this_ptr_conv.is_owned = false;
24709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24710         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24711 }
24712
24713 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24714         LDKChannelDetails this_ptr_conv;
24715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24716         this_ptr_conv.is_owned = false;
24717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24718         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24719         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24720         uint32_t ret_ref = (uintptr_t)ret_copy;
24721         return ret_ref;
24722 }
24723
24724 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24725         LDKChannelDetails this_ptr_conv;
24726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24727         this_ptr_conv.is_owned = false;
24728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24729         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24730         CHECK_ACCESS(val_ptr);
24731         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24732         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24733         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24734 }
24735
24736 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24737         LDKChannelDetails this_ptr_conv;
24738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24739         this_ptr_conv.is_owned = false;
24740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24741         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24742         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24743         uint32_t ret_ref = (uintptr_t)ret_copy;
24744         return ret_ref;
24745 }
24746
24747 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) {
24748         LDKChannelDetails this_ptr_conv;
24749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24750         this_ptr_conv.is_owned = false;
24751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24752         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24753         CHECK_ACCESS(val_ptr);
24754         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24755         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24756         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24757 }
24758
24759 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24760         LDKChannelDetails this_ptr_conv;
24761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24762         this_ptr_conv.is_owned = false;
24763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24764         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24765         return ret_val;
24766 }
24767
24768 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
24769         LDKChannelDetails this_ptr_conv;
24770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24771         this_ptr_conv.is_owned = false;
24772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24773         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24774 }
24775
24776 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24777         LDKChannelDetails this_ptr_conv;
24778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24779         this_ptr_conv.is_owned = false;
24780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24781         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24782         return ret_val;
24783 }
24784
24785 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24786         LDKChannelDetails this_ptr_conv;
24787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24788         this_ptr_conv.is_owned = false;
24789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24790         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24791 }
24792
24793 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24794         LDKChannelDetails this_ptr_conv;
24795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24796         this_ptr_conv.is_owned = false;
24797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24798         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24799         return ret_val;
24800 }
24801
24802 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24803         LDKChannelDetails 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         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24808 }
24809
24810 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24811         LDKChannelDetails this_ptr_conv;
24812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24813         this_ptr_conv.is_owned = false;
24814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24815         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24816         return ret_val;
24817 }
24818
24819 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24820         LDKChannelDetails this_ptr_conv;
24821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24822         this_ptr_conv.is_owned = false;
24823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24824         ChannelDetails_set_is_public(&this_ptr_conv, val);
24825 }
24826
24827 uint32_t  __attribute__((export_name("TS_ChannelDetails_new"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t channel_type_arg, uint32_t short_channel_id_arg, uint32_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
24828         LDKThirtyTwoBytes channel_id_arg_ref;
24829         CHECK(channel_id_arg->arr_len == 32);
24830         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24831         LDKChannelCounterparty counterparty_arg_conv;
24832         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24833         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24834         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24835         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24836         LDKOutPoint funding_txo_arg_conv;
24837         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24838         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24839         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24840         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24841         LDKChannelTypeFeatures channel_type_arg_conv;
24842         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
24843         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
24844         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
24845         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
24846         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24847         CHECK_ACCESS(short_channel_id_arg_ptr);
24848         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24849         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24850         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
24851         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
24852         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
24853         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
24854         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24855         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24856         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24857         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24858         CHECK_ACCESS(confirmations_required_arg_ptr);
24859         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24860         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24861         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24862         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24863         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24864         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24865         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
24866         uint32_t ret_ref = 0;
24867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24870         ret_ref = (uintptr_t)ret_var.inner;
24871         if (ret_var.is_owned) {
24872                 ret_ref |= 1;
24873         }
24874         return ret_ref;
24875 }
24876
24877 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24878         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24879 uint32_t ret_ref = 0;
24880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24883 ret_ref = (uintptr_t)ret_var.inner;
24884 if (ret_var.is_owned) {
24885         ret_ref |= 1;
24886 }
24887         return ret_ref;
24888 }
24889 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24890         LDKChannelDetails arg_conv;
24891         arg_conv.inner = (void*)(arg & (~1));
24892         arg_conv.is_owned = false;
24893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24894         uint32_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24895         return ret_val;
24896 }
24897
24898 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24899         LDKChannelDetails orig_conv;
24900         orig_conv.inner = (void*)(orig & (~1));
24901         orig_conv.is_owned = false;
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24903         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24904         uint32_t ret_ref = 0;
24905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24908         ret_ref = (uintptr_t)ret_var.inner;
24909         if (ret_var.is_owned) {
24910                 ret_ref |= 1;
24911         }
24912         return ret_ref;
24913 }
24914
24915 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
24916         LDKChannelDetails this_arg_conv;
24917         this_arg_conv.inner = (void*)(this_arg & (~1));
24918         this_arg_conv.is_owned = false;
24919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24920         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24921         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
24922         uint32_t ret_ref = (uintptr_t)ret_copy;
24923         return ret_ref;
24924 }
24925
24926 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24927         if ((this_ptr & 1) != 0) return;
24928         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24929         CHECK_ACCESS(this_ptr_ptr);
24930         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24931         FREE((void*)this_ptr);
24932         PaymentSendFailure_free(this_ptr_conv);
24933 }
24934
24935 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24936         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24937         *ret_copy = PaymentSendFailure_clone(arg);
24938 uint32_t ret_ref = (uintptr_t)ret_copy;
24939         return ret_ref;
24940 }
24941 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
24942         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24943         uint32_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24944         return ret_val;
24945 }
24946
24947 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
24948         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24949         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24950         *ret_copy = PaymentSendFailure_clone(orig_conv);
24951         uint32_t ret_ref = (uintptr_t)ret_copy;
24952         return ret_ref;
24953 }
24954
24955 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
24956         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
24957         CHECK_ACCESS(a_ptr);
24958         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24959         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
24960         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24961         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24962         uint32_t ret_ref = (uintptr_t)ret_copy;
24963         return ret_ref;
24964 }
24965
24966 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
24967         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24968         a_constr.datalen = a->arr_len;
24969         if (a_constr.datalen > 0)
24970                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24971         else
24972                 a_constr.data = NULL;
24973         uint32_t* a_vals = a->elems /* XXX a leaks */;
24974         for (size_t w = 0; w < a_constr.datalen; w++) {
24975                 uint32_t a_conv_22 = a_vals[w];
24976                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
24977                 CHECK_ACCESS(a_conv_22_ptr);
24978                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24979                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
24980                 a_constr.data[w] = a_conv_22_conv;
24981         }
24982         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24983         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24984         uint32_t ret_ref = (uintptr_t)ret_copy;
24985         return ret_ref;
24986 }
24987
24988 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
24989         LDKCVec_APIErrorZ a_constr;
24990         a_constr.datalen = a->arr_len;
24991         if (a_constr.datalen > 0)
24992                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24993         else
24994                 a_constr.data = NULL;
24995         uint32_t* a_vals = a->elems /* XXX a leaks */;
24996         for (size_t k = 0; k < a_constr.datalen; k++) {
24997                 uint32_t a_conv_10 = a_vals[k];
24998                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
24999                 CHECK_ACCESS(a_conv_10_ptr);
25000                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
25001                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
25002                 a_constr.data[k] = a_conv_10_conv;
25003         }
25004         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25005         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25006         uint32_t ret_ref = (uintptr_t)ret_copy;
25007         return ret_ref;
25008 }
25009
25010 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) {
25011         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25012         results_constr.datalen = results->arr_len;
25013         if (results_constr.datalen > 0)
25014                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25015         else
25016                 results_constr.data = NULL;
25017         uint32_t* results_vals = results->elems /* XXX results leaks */;
25018         for (size_t w = 0; w < results_constr.datalen; w++) {
25019                 uint32_t results_conv_22 = results_vals[w];
25020                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
25021                 CHECK_ACCESS(results_conv_22_ptr);
25022                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25023                 results_constr.data[w] = results_conv_22_conv;
25024         }
25025         LDKRouteParameters failed_paths_retry_conv;
25026         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25027         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25029         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25030         LDKThirtyTwoBytes payment_id_ref;
25031         CHECK(payment_id->arr_len == 32);
25032         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25033         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25034         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25035         uint32_t ret_ref = (uintptr_t)ret_copy;
25036         return ret_ref;
25037 }
25038
25039 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
25040         LDKPhantomRouteHints this_obj_conv;
25041         this_obj_conv.inner = (void*)(this_obj & (~1));
25042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25044         PhantomRouteHints_free(this_obj_conv);
25045 }
25046
25047 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
25048         LDKPhantomRouteHints this_ptr_conv;
25049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25050         this_ptr_conv.is_owned = false;
25051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25052         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
25053         uint32_tArray ret_arr = NULL;
25054         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25055         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25056         for (size_t q = 0; q < ret_var.datalen; q++) {
25057                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25058                 uint32_t ret_conv_16_ref = 0;
25059                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25060                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25061                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25062                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25063                 if (ret_conv_16_var.is_owned) {
25064                         ret_conv_16_ref |= 1;
25065                 }
25066                 ret_arr_ptr[q] = ret_conv_16_ref;
25067         }
25068         
25069         FREE(ret_var.data);
25070         return ret_arr;
25071 }
25072
25073 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
25074         LDKPhantomRouteHints this_ptr_conv;
25075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25076         this_ptr_conv.is_owned = false;
25077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25078         LDKCVec_ChannelDetailsZ val_constr;
25079         val_constr.datalen = val->arr_len;
25080         if (val_constr.datalen > 0)
25081                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25082         else
25083                 val_constr.data = NULL;
25084         uint32_t* val_vals = val->elems /* XXX val leaks */;
25085         for (size_t q = 0; q < val_constr.datalen; q++) {
25086                 uint32_t val_conv_16 = val_vals[q];
25087                 LDKChannelDetails val_conv_16_conv;
25088                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25089                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25090                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
25091                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
25092                 val_constr.data[q] = val_conv_16_conv;
25093         }
25094         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
25095 }
25096
25097 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
25098         LDKPhantomRouteHints this_ptr_conv;
25099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25100         this_ptr_conv.is_owned = false;
25101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25102         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
25103         return ret_val;
25104 }
25105
25106 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
25107         LDKPhantomRouteHints this_ptr_conv;
25108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25109         this_ptr_conv.is_owned = false;
25110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25111         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
25112 }
25113
25114 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
25115         LDKPhantomRouteHints this_ptr_conv;
25116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25117         this_ptr_conv.is_owned = false;
25118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25119         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25120         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
25121         return ret_arr;
25122 }
25123
25124 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
25125         LDKPhantomRouteHints this_ptr_conv;
25126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25127         this_ptr_conv.is_owned = false;
25128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25129         LDKPublicKey val_ref;
25130         CHECK(val->arr_len == 33);
25131         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25132         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
25133 }
25134
25135 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_new"))) TS_PhantomRouteHints_new(uint32_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
25136         LDKCVec_ChannelDetailsZ channels_arg_constr;
25137         channels_arg_constr.datalen = channels_arg->arr_len;
25138         if (channels_arg_constr.datalen > 0)
25139                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25140         else
25141                 channels_arg_constr.data = NULL;
25142         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
25143         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
25144                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
25145                 LDKChannelDetails channels_arg_conv_16_conv;
25146                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
25147                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
25148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
25149                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
25150                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
25151         }
25152         LDKPublicKey real_node_pubkey_arg_ref;
25153         CHECK(real_node_pubkey_arg->arr_len == 33);
25154         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
25155         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
25156         uint32_t ret_ref = 0;
25157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25160         ret_ref = (uintptr_t)ret_var.inner;
25161         if (ret_var.is_owned) {
25162                 ret_ref |= 1;
25163         }
25164         return ret_ref;
25165 }
25166
25167 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
25168         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
25169 uint32_t ret_ref = 0;
25170 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25171 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25173 ret_ref = (uintptr_t)ret_var.inner;
25174 if (ret_var.is_owned) {
25175         ret_ref |= 1;
25176 }
25177         return ret_ref;
25178 }
25179 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
25180         LDKPhantomRouteHints arg_conv;
25181         arg_conv.inner = (void*)(arg & (~1));
25182         arg_conv.is_owned = false;
25183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25184         uint32_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
25185         return ret_val;
25186 }
25187
25188 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
25189         LDKPhantomRouteHints orig_conv;
25190         orig_conv.inner = (void*)(orig & (~1));
25191         orig_conv.is_owned = false;
25192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25193         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
25194         uint32_t ret_ref = 0;
25195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25198         ret_ref = (uintptr_t)ret_var.inner;
25199         if (ret_var.is_owned) {
25200                 ret_ref |= 1;
25201         }
25202         return ret_ref;
25203 }
25204
25205 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) {
25206         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
25207         CHECK_ACCESS(fee_est_ptr);
25208         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
25209         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
25210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25211                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
25212         }
25213         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25214         CHECK_ACCESS(chain_monitor_ptr);
25215         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25216         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25217                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25218                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25219         }
25220         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25221         CHECK_ACCESS(tx_broadcaster_ptr);
25222         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25223         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25225                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25226         }
25227         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25228         CHECK_ACCESS(logger_ptr);
25229         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25230         if (logger_conv.free == LDKLogger_JCalls_free) {
25231                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25232                 LDKLogger_JCalls_cloned(&logger_conv);
25233         }
25234         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25235         CHECK_ACCESS(keys_manager_ptr);
25236         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25237         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25238                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25239                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25240         }
25241         LDKUserConfig config_conv;
25242         config_conv.inner = (void*)(config & (~1));
25243         config_conv.is_owned = (config & 1) || (config == 0);
25244         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
25245         config_conv = UserConfig_clone(&config_conv);
25246         LDKChainParameters params_conv;
25247         params_conv.inner = (void*)(params & (~1));
25248         params_conv.is_owned = (params & 1) || (params == 0);
25249         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
25250         params_conv = ChainParameters_clone(&params_conv);
25251         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
25252         uint32_t ret_ref = 0;
25253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25256         ret_ref = (uintptr_t)ret_var.inner;
25257         if (ret_var.is_owned) {
25258                 ret_ref |= 1;
25259         }
25260         return ret_ref;
25261 }
25262
25263 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
25264         LDKChannelManager this_arg_conv;
25265         this_arg_conv.inner = (void*)(this_arg & (~1));
25266         this_arg_conv.is_owned = false;
25267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25268         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
25269         uint32_t ret_ref = 0;
25270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25273         ret_ref = (uintptr_t)ret_var.inner;
25274         if (ret_var.is_owned) {
25275                 ret_ref |= 1;
25276         }
25277         return ret_ref;
25278 }
25279
25280 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) {
25281         LDKChannelManager this_arg_conv;
25282         this_arg_conv.inner = (void*)(this_arg & (~1));
25283         this_arg_conv.is_owned = false;
25284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25285         LDKPublicKey their_network_key_ref;
25286         CHECK(their_network_key->arr_len == 33);
25287         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
25288         LDKUserConfig override_config_conv;
25289         override_config_conv.inner = (void*)(override_config & (~1));
25290         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
25291         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
25292         override_config_conv = UserConfig_clone(&override_config_conv);
25293         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
25294         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
25295         return (uint32_t)ret_conv;
25296 }
25297
25298 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
25299         LDKChannelManager this_arg_conv;
25300         this_arg_conv.inner = (void*)(this_arg & (~1));
25301         this_arg_conv.is_owned = false;
25302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25303         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
25304         uint32_tArray ret_arr = NULL;
25305         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25306         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25307         for (size_t q = 0; q < ret_var.datalen; q++) {
25308                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25309                 uint32_t ret_conv_16_ref = 0;
25310                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25311                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25312                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25313                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25314                 if (ret_conv_16_var.is_owned) {
25315                         ret_conv_16_ref |= 1;
25316                 }
25317                 ret_arr_ptr[q] = ret_conv_16_ref;
25318         }
25319         
25320         FREE(ret_var.data);
25321         return ret_arr;
25322 }
25323
25324 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
25325         LDKChannelManager this_arg_conv;
25326         this_arg_conv.inner = (void*)(this_arg & (~1));
25327         this_arg_conv.is_owned = false;
25328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25329         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25330         uint32_tArray ret_arr = NULL;
25331         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25332         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25333         for (size_t q = 0; q < ret_var.datalen; q++) {
25334                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25335                 uint32_t ret_conv_16_ref = 0;
25336                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25337                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25338                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25339                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25340                 if (ret_conv_16_var.is_owned) {
25341                         ret_conv_16_ref |= 1;
25342                 }
25343                 ret_arr_ptr[q] = ret_conv_16_ref;
25344         }
25345         
25346         FREE(ret_var.data);
25347         return ret_arr;
25348 }
25349
25350 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25351         LDKChannelManager this_arg_conv;
25352         this_arg_conv.inner = (void*)(this_arg & (~1));
25353         this_arg_conv.is_owned = false;
25354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25355         unsigned char channel_id_arr[32];
25356         CHECK(channel_id->arr_len == 32);
25357         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25358         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25359         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25360         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25361         return (uint32_t)ret_conv;
25362 }
25363
25364 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) {
25365         LDKChannelManager this_arg_conv;
25366         this_arg_conv.inner = (void*)(this_arg & (~1));
25367         this_arg_conv.is_owned = false;
25368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25369         unsigned char channel_id_arr[32];
25370         CHECK(channel_id->arr_len == 32);
25371         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25372         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25373         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25374         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25375         return (uint32_t)ret_conv;
25376 }
25377
25378 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25379         LDKChannelManager this_arg_conv;
25380         this_arg_conv.inner = (void*)(this_arg & (~1));
25381         this_arg_conv.is_owned = false;
25382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25383         unsigned char channel_id_arr[32];
25384         CHECK(channel_id->arr_len == 32);
25385         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25386         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25387         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25388         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25389         return (uint32_t)ret_conv;
25390 }
25391
25392 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
25393         LDKChannelManager this_arg_conv;
25394         this_arg_conv.inner = (void*)(this_arg & (~1));
25395         this_arg_conv.is_owned = false;
25396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25397         ChannelManager_force_close_all_channels(&this_arg_conv);
25398 }
25399
25400 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) {
25401         LDKChannelManager this_arg_conv;
25402         this_arg_conv.inner = (void*)(this_arg & (~1));
25403         this_arg_conv.is_owned = false;
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25405         LDKRoute route_conv;
25406         route_conv.inner = (void*)(route & (~1));
25407         route_conv.is_owned = false;
25408         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25409         LDKThirtyTwoBytes payment_hash_ref;
25410         CHECK(payment_hash->arr_len == 32);
25411         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25412         LDKThirtyTwoBytes payment_secret_ref;
25413         CHECK(payment_secret->arr_len == 32);
25414         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25415         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25416         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25417         return (uint32_t)ret_conv;
25418 }
25419
25420 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
25421         LDKChannelManager this_arg_conv;
25422         this_arg_conv.inner = (void*)(this_arg & (~1));
25423         this_arg_conv.is_owned = false;
25424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25425         LDKRoute route_conv;
25426         route_conv.inner = (void*)(route & (~1));
25427         route_conv.is_owned = false;
25428         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25429         LDKThirtyTwoBytes payment_id_ref;
25430         CHECK(payment_id->arr_len == 32);
25431         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25432         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25433         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25434         return (uint32_t)ret_conv;
25435 }
25436
25437 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
25438         LDKChannelManager this_arg_conv;
25439         this_arg_conv.inner = (void*)(this_arg & (~1));
25440         this_arg_conv.is_owned = false;
25441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25442         LDKThirtyTwoBytes payment_id_ref;
25443         CHECK(payment_id->arr_len == 32);
25444         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25445         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25446 }
25447
25448 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) {
25449         LDKChannelManager this_arg_conv;
25450         this_arg_conv.inner = (void*)(this_arg & (~1));
25451         this_arg_conv.is_owned = false;
25452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25453         LDKRoute route_conv;
25454         route_conv.inner = (void*)(route & (~1));
25455         route_conv.is_owned = false;
25456         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25457         LDKThirtyTwoBytes payment_preimage_ref;
25458         CHECK(payment_preimage->arr_len == 32);
25459         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25460         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25461         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25462         return (uint32_t)ret_conv;
25463 }
25464
25465 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) {
25466         LDKChannelManager this_arg_conv;
25467         this_arg_conv.inner = (void*)(this_arg & (~1));
25468         this_arg_conv.is_owned = false;
25469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25470         unsigned char temporary_channel_id_arr[32];
25471         CHECK(temporary_channel_id->arr_len == 32);
25472         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25473         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25474         LDKTransaction funding_transaction_ref;
25475         funding_transaction_ref.datalen = funding_transaction->arr_len;
25476         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25477         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25478         funding_transaction_ref.data_is_owned = true;
25479         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25480         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25481         return (uint32_t)ret_conv;
25482 }
25483
25484 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) {
25485         LDKChannelManager this_arg_conv;
25486         this_arg_conv.inner = (void*)(this_arg & (~1));
25487         this_arg_conv.is_owned = false;
25488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25489         LDKThreeBytes rgb_ref;
25490         CHECK(rgb->arr_len == 3);
25491         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25492         LDKThirtyTwoBytes alias_ref;
25493         CHECK(alias->arr_len == 32);
25494         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25495         LDKCVec_NetAddressZ addresses_constr;
25496         addresses_constr.datalen = addresses->arr_len;
25497         if (addresses_constr.datalen > 0)
25498                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25499         else
25500                 addresses_constr.data = NULL;
25501         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25502         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25503                 uint32_t addresses_conv_12 = addresses_vals[m];
25504                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25505                 CHECK_ACCESS(addresses_conv_12_ptr);
25506                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25507                 addresses_constr.data[m] = addresses_conv_12_conv;
25508         }
25509         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25510 }
25511
25512 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25513         LDKChannelManager this_arg_conv;
25514         this_arg_conv.inner = (void*)(this_arg & (~1));
25515         this_arg_conv.is_owned = false;
25516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25517         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25518 }
25519
25520 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25521         LDKChannelManager this_arg_conv;
25522         this_arg_conv.inner = (void*)(this_arg & (~1));
25523         this_arg_conv.is_owned = false;
25524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25525         ChannelManager_timer_tick_occurred(&this_arg_conv);
25526 }
25527
25528 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25529         LDKChannelManager this_arg_conv;
25530         this_arg_conv.inner = (void*)(this_arg & (~1));
25531         this_arg_conv.is_owned = false;
25532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25533         unsigned char payment_hash_arr[32];
25534         CHECK(payment_hash->arr_len == 32);
25535         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25536         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25537         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25538         return ret_val;
25539 }
25540
25541 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25542         LDKChannelManager this_arg_conv;
25543         this_arg_conv.inner = (void*)(this_arg & (~1));
25544         this_arg_conv.is_owned = false;
25545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25546         LDKThirtyTwoBytes payment_preimage_ref;
25547         CHECK(payment_preimage->arr_len == 32);
25548         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25549         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25550         return ret_val;
25551 }
25552
25553 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25554         LDKChannelManager this_arg_conv;
25555         this_arg_conv.inner = (void*)(this_arg & (~1));
25556         this_arg_conv.is_owned = false;
25557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25558         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25559         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25560         return ret_arr;
25561 }
25562
25563 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id, int64_t user_channel_id) {
25564         LDKChannelManager this_arg_conv;
25565         this_arg_conv.inner = (void*)(this_arg & (~1));
25566         this_arg_conv.is_owned = false;
25567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25568         unsigned char temporary_channel_id_arr[32];
25569         CHECK(temporary_channel_id->arr_len == 32);
25570         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25571         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25572         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25573         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
25574         return (uint32_t)ret_conv;
25575 }
25576
25577 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) {
25578         LDKChannelManager this_arg_conv;
25579         this_arg_conv.inner = (void*)(this_arg & (~1));
25580         this_arg_conv.is_owned = false;
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25582         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25583         CHECK_ACCESS(min_value_msat_ptr);
25584         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25585         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25586         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25587         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25588         return (uint32_t)ret_conv;
25589 }
25590
25591 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) {
25592         LDKChannelManager this_arg_conv;
25593         this_arg_conv.inner = (void*)(this_arg & (~1));
25594         this_arg_conv.is_owned = false;
25595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25596         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25597         CHECK_ACCESS(min_value_msat_ptr);
25598         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25599         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25600         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25601         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25602         return (uint32_t)ret_conv;
25603 }
25604
25605 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) {
25606         LDKChannelManager this_arg_conv;
25607         this_arg_conv.inner = (void*)(this_arg & (~1));
25608         this_arg_conv.is_owned = false;
25609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25610         LDKThirtyTwoBytes payment_hash_ref;
25611         CHECK(payment_hash->arr_len == 32);
25612         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25613         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25614         CHECK_ACCESS(min_value_msat_ptr);
25615         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25616         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25617         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25618         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25619         return (uint32_t)ret_conv;
25620 }
25621
25622 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) {
25623         LDKChannelManager this_arg_conv;
25624         this_arg_conv.inner = (void*)(this_arg & (~1));
25625         this_arg_conv.is_owned = false;
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25627         LDKThirtyTwoBytes payment_hash_ref;
25628         CHECK(payment_hash->arr_len == 32);
25629         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25630         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25631         CHECK_ACCESS(min_value_msat_ptr);
25632         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25633         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25634         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25635         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25636         return (uint32_t)ret_conv;
25637 }
25638
25639 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) {
25640         LDKChannelManager this_arg_conv;
25641         this_arg_conv.inner = (void*)(this_arg & (~1));
25642         this_arg_conv.is_owned = false;
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25644         LDKThirtyTwoBytes payment_hash_ref;
25645         CHECK(payment_hash->arr_len == 32);
25646         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25647         LDKThirtyTwoBytes payment_secret_ref;
25648         CHECK(payment_secret->arr_len == 32);
25649         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25650         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25651         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25652         return (uint32_t)ret_conv;
25653 }
25654
25655 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25656         LDKChannelManager this_arg_conv;
25657         this_arg_conv.inner = (void*)(this_arg & (~1));
25658         this_arg_conv.is_owned = false;
25659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25660         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
25661         return ret_val;
25662 }
25663
25664 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25665         LDKChannelManager this_arg_conv;
25666         this_arg_conv.inner = (void*)(this_arg & (~1));
25667         this_arg_conv.is_owned = false;
25668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25669         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25670         uint32_t ret_ref = 0;
25671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25674         ret_ref = (uintptr_t)ret_var.inner;
25675         if (ret_var.is_owned) {
25676                 ret_ref |= 1;
25677         }
25678         return ret_ref;
25679 }
25680
25681 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25682         LDKChannelManager this_arg_conv;
25683         this_arg_conv.inner = (void*)(this_arg & (~1));
25684         this_arg_conv.is_owned = false;
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25686         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25687         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25688         return (uint32_t)ret_ret;
25689 }
25690
25691 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25692         LDKChannelManager this_arg_conv;
25693         this_arg_conv.inner = (void*)(this_arg & (~1));
25694         this_arg_conv.is_owned = false;
25695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25696         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25697         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25698         return (uint32_t)ret_ret;
25699 }
25700
25701 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25702         LDKChannelManager this_arg_conv;
25703         this_arg_conv.inner = (void*)(this_arg & (~1));
25704         this_arg_conv.is_owned = false;
25705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25706         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25707         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25708         return (uint32_t)ret_ret;
25709 }
25710
25711 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25712         LDKChannelManager this_arg_conv;
25713         this_arg_conv.inner = (void*)(this_arg & (~1));
25714         this_arg_conv.is_owned = false;
25715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25716         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25717         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25718         return (uint32_t)ret_ret;
25719 }
25720
25721 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25722         LDKChannelManager this_arg_conv;
25723         this_arg_conv.inner = (void*)(this_arg & (~1));
25724         this_arg_conv.is_owned = false;
25725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25726         ChannelManager_await_persistable_update(&this_arg_conv);
25727 }
25728
25729 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25730         LDKChannelManager this_arg_conv;
25731         this_arg_conv.inner = (void*)(this_arg & (~1));
25732         this_arg_conv.is_owned = false;
25733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25734         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25735         uint32_t ret_ref = 0;
25736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25739         ret_ref = (uintptr_t)ret_var.inner;
25740         if (ret_var.is_owned) {
25741                 ret_ref |= 1;
25742         }
25743         return ret_ref;
25744 }
25745
25746 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25747         LDKChannelManager this_arg_conv;
25748         this_arg_conv.inner = (void*)(this_arg & (~1));
25749         this_arg_conv.is_owned = false;
25750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25751         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25752         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25753         return (uint32_t)ret_ret;
25754 }
25755
25756 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25757         LDKCounterpartyForwardingInfo obj_conv;
25758         obj_conv.inner = (void*)(obj & (~1));
25759         obj_conv.is_owned = false;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25761         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25762         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25763         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25764         CVec_u8Z_free(ret_var);
25765         return ret_arr;
25766 }
25767
25768 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25769         LDKu8slice ser_ref;
25770         ser_ref.datalen = ser->arr_len;
25771         ser_ref.data = ser->elems /* XXX ser leaks */;
25772         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25773         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25774         return (uint32_t)ret_conv;
25775 }
25776
25777 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25778         LDKChannelCounterparty obj_conv;
25779         obj_conv.inner = (void*)(obj & (~1));
25780         obj_conv.is_owned = false;
25781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25782         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25785         CVec_u8Z_free(ret_var);
25786         return ret_arr;
25787 }
25788
25789 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25790         LDKu8slice ser_ref;
25791         ser_ref.datalen = ser->arr_len;
25792         ser_ref.data = ser->elems /* XXX ser leaks */;
25793         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25794         *ret_conv = ChannelCounterparty_read(ser_ref);
25795         return (uint32_t)ret_conv;
25796 }
25797
25798 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25799         LDKChannelDetails obj_conv;
25800         obj_conv.inner = (void*)(obj & (~1));
25801         obj_conv.is_owned = false;
25802         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25803         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25804         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25805         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25806         CVec_u8Z_free(ret_var);
25807         return ret_arr;
25808 }
25809
25810 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25811         LDKu8slice ser_ref;
25812         ser_ref.datalen = ser->arr_len;
25813         ser_ref.data = ser->elems /* XXX ser leaks */;
25814         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25815         *ret_conv = ChannelDetails_read(ser_ref);
25816         return (uint32_t)ret_conv;
25817 }
25818
25819 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25820         LDKPhantomRouteHints obj_conv;
25821         obj_conv.inner = (void*)(obj & (~1));
25822         obj_conv.is_owned = false;
25823         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25824         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25825         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25826         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25827         CVec_u8Z_free(ret_var);
25828         return ret_arr;
25829 }
25830
25831 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25832         LDKu8slice ser_ref;
25833         ser_ref.datalen = ser->arr_len;
25834         ser_ref.data = ser->elems /* XXX ser leaks */;
25835         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25836         *ret_conv = PhantomRouteHints_read(ser_ref);
25837         return (uint32_t)ret_conv;
25838 }
25839
25840 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25841         LDKChannelManager obj_conv;
25842         obj_conv.inner = (void*)(obj & (~1));
25843         obj_conv.is_owned = false;
25844         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25845         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25846         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25847         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25848         CVec_u8Z_free(ret_var);
25849         return ret_arr;
25850 }
25851
25852 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25853         LDKChannelManagerReadArgs this_obj_conv;
25854         this_obj_conv.inner = (void*)(this_obj & (~1));
25855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25857         ChannelManagerReadArgs_free(this_obj_conv);
25858 }
25859
25860 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25861         LDKChannelManagerReadArgs this_ptr_conv;
25862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25863         this_ptr_conv.is_owned = false;
25864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25865         // WARNING: This object doesn't live past this scope, needs clone!
25866         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25867         return ret_ret;
25868 }
25869
25870 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25871         LDKChannelManagerReadArgs this_ptr_conv;
25872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25873         this_ptr_conv.is_owned = false;
25874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25875         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25876         CHECK_ACCESS(val_ptr);
25877         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25878         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25879                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25880                 LDKKeysInterface_JCalls_cloned(&val_conv);
25881         }
25882         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25883 }
25884
25885 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25886         LDKChannelManagerReadArgs this_ptr_conv;
25887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25888         this_ptr_conv.is_owned = false;
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25890         // WARNING: This object doesn't live past this scope, needs clone!
25891         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25892         return ret_ret;
25893 }
25894
25895 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25896         LDKChannelManagerReadArgs this_ptr_conv;
25897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25898         this_ptr_conv.is_owned = false;
25899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25900         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25901         CHECK_ACCESS(val_ptr);
25902         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25903         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25904                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25905                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25906         }
25907         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25908 }
25909
25910 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25911         LDKChannelManagerReadArgs this_ptr_conv;
25912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25913         this_ptr_conv.is_owned = false;
25914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25915         // WARNING: This object doesn't live past this scope, needs clone!
25916         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25917         return ret_ret;
25918 }
25919
25920 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25921         LDKChannelManagerReadArgs this_ptr_conv;
25922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25923         this_ptr_conv.is_owned = false;
25924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25925         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25926         CHECK_ACCESS(val_ptr);
25927         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25928         if (val_conv.free == LDKWatch_JCalls_free) {
25929                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25930                 LDKWatch_JCalls_cloned(&val_conv);
25931         }
25932         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25933 }
25934
25935 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25936         LDKChannelManagerReadArgs this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25940         // WARNING: This object doesn't live past this scope, needs clone!
25941         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25942         return ret_ret;
25943 }
25944
25945 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
25946         LDKChannelManagerReadArgs this_ptr_conv;
25947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25948         this_ptr_conv.is_owned = false;
25949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25950         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25951         CHECK_ACCESS(val_ptr);
25952         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25953         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
25954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25955                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
25956         }
25957         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25958 }
25959
25960 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
25961         LDKChannelManagerReadArgs this_ptr_conv;
25962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25963         this_ptr_conv.is_owned = false;
25964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25965         // WARNING: This object doesn't live past this scope, needs clone!
25966         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25967         return ret_ret;
25968 }
25969
25970 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
25971         LDKChannelManagerReadArgs this_ptr_conv;
25972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25973         this_ptr_conv.is_owned = false;
25974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25975         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25976         CHECK_ACCESS(val_ptr);
25977         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25978         if (val_conv.free == LDKLogger_JCalls_free) {
25979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25980                 LDKLogger_JCalls_cloned(&val_conv);
25981         }
25982         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25983 }
25984
25985 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
25986         LDKChannelManagerReadArgs this_ptr_conv;
25987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25988         this_ptr_conv.is_owned = false;
25989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25990         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25991         uint32_t ret_ref = 0;
25992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25995         ret_ref = (uintptr_t)ret_var.inner;
25996         if (ret_var.is_owned) {
25997                 ret_ref |= 1;
25998         }
25999         return ret_ref;
26000 }
26001
26002 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
26003         LDKChannelManagerReadArgs 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         LDKUserConfig val_conv;
26008         val_conv.inner = (void*)(val & (~1));
26009         val_conv.is_owned = (val & 1) || (val == 0);
26010         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26011         val_conv = UserConfig_clone(&val_conv);
26012         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
26013 }
26014
26015 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) {
26016         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26017         CHECK_ACCESS(keys_manager_ptr);
26018         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26019         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26021                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26022         }
26023         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26024         CHECK_ACCESS(fee_estimator_ptr);
26025         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26026         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26027                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26028                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26029         }
26030         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26031         CHECK_ACCESS(chain_monitor_ptr);
26032         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26033         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26034                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26035                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26036         }
26037         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26038         CHECK_ACCESS(tx_broadcaster_ptr);
26039         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26040         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26042                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26043         }
26044         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26045         CHECK_ACCESS(logger_ptr);
26046         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26047         if (logger_conv.free == LDKLogger_JCalls_free) {
26048                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26049                 LDKLogger_JCalls_cloned(&logger_conv);
26050         }
26051         LDKUserConfig default_config_conv;
26052         default_config_conv.inner = (void*)(default_config & (~1));
26053         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26054         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26055         default_config_conv = UserConfig_clone(&default_config_conv);
26056         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26057         channel_monitors_constr.datalen = channel_monitors->arr_len;
26058         if (channel_monitors_constr.datalen > 0)
26059                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26060         else
26061                 channel_monitors_constr.data = NULL;
26062         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
26063         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26064                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
26065                 LDKChannelMonitor channel_monitors_conv_16_conv;
26066                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26067                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26068                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26069                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26070         }
26071         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);
26072         uint32_t ret_ref = 0;
26073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26076         ret_ref = (uintptr_t)ret_var.inner;
26077         if (ret_var.is_owned) {
26078                 ret_ref |= 1;
26079         }
26080         return ret_ref;
26081 }
26082
26083 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
26084         LDKu8slice ser_ref;
26085         ser_ref.datalen = ser->arr_len;
26086         ser_ref.data = ser->elems /* XXX ser leaks */;
26087         LDKChannelManagerReadArgs arg_conv;
26088         arg_conv.inner = (void*)(arg & (~1));
26089         arg_conv.is_owned = (arg & 1) || (arg == 0);
26090         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26091         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
26092         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26093         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26094         return (uint32_t)ret_conv;
26095 }
26096
26097 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
26098         LDKDecodeError this_obj_conv;
26099         this_obj_conv.inner = (void*)(this_obj & (~1));
26100         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26102         DecodeError_free(this_obj_conv);
26103 }
26104
26105 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
26106         LDKDecodeError ret_var = DecodeError_clone(arg);
26107 uint32_t ret_ref = 0;
26108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26111 ret_ref = (uintptr_t)ret_var.inner;
26112 if (ret_var.is_owned) {
26113         ret_ref |= 1;
26114 }
26115         return ret_ref;
26116 }
26117 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
26118         LDKDecodeError arg_conv;
26119         arg_conv.inner = (void*)(arg & (~1));
26120         arg_conv.is_owned = false;
26121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26122         uint32_t ret_val = DecodeError_clone_ptr(&arg_conv);
26123         return ret_val;
26124 }
26125
26126 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
26127         LDKDecodeError orig_conv;
26128         orig_conv.inner = (void*)(orig & (~1));
26129         orig_conv.is_owned = false;
26130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26131         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
26132         uint32_t ret_ref = 0;
26133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26136         ret_ref = (uintptr_t)ret_var.inner;
26137         if (ret_var.is_owned) {
26138                 ret_ref |= 1;
26139         }
26140         return ret_ref;
26141 }
26142
26143 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
26144         LDKInit this_obj_conv;
26145         this_obj_conv.inner = (void*)(this_obj & (~1));
26146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26148         Init_free(this_obj_conv);
26149 }
26150
26151 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
26152         LDKInit this_ptr_conv;
26153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26154         this_ptr_conv.is_owned = false;
26155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26156         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
26157         uint32_t ret_ref = 0;
26158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26161         ret_ref = (uintptr_t)ret_var.inner;
26162         if (ret_var.is_owned) {
26163                 ret_ref |= 1;
26164         }
26165         return ret_ref;
26166 }
26167
26168 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
26169         LDKInit this_ptr_conv;
26170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26171         this_ptr_conv.is_owned = false;
26172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26173         LDKInitFeatures val_conv;
26174         val_conv.inner = (void*)(val & (~1));
26175         val_conv.is_owned = (val & 1) || (val == 0);
26176         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26177         val_conv = InitFeatures_clone(&val_conv);
26178         Init_set_features(&this_ptr_conv, val_conv);
26179 }
26180
26181 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
26182         LDKInit this_ptr_conv;
26183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26184         this_ptr_conv.is_owned = false;
26185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26186         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
26187         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
26188         uint32_t ret_ref = (uintptr_t)ret_copy;
26189         return ret_ref;
26190 }
26191
26192 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
26193         LDKInit this_ptr_conv;
26194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26195         this_ptr_conv.is_owned = false;
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26197         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26198         CHECK_ACCESS(val_ptr);
26199         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
26200         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
26201         Init_set_remote_network_address(&this_ptr_conv, val_conv);
26202 }
26203
26204 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
26205         LDKInitFeatures features_arg_conv;
26206         features_arg_conv.inner = (void*)(features_arg & (~1));
26207         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26208         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26209         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26210         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
26211         CHECK_ACCESS(remote_network_address_arg_ptr);
26212         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
26213         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
26214         uint32_t ret_ref = 0;
26215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26218         ret_ref = (uintptr_t)ret_var.inner;
26219         if (ret_var.is_owned) {
26220                 ret_ref |= 1;
26221         }
26222         return ret_ref;
26223 }
26224
26225 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
26226         LDKInit ret_var = Init_clone(arg);
26227 uint32_t ret_ref = 0;
26228 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26229 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26230 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26231 ret_ref = (uintptr_t)ret_var.inner;
26232 if (ret_var.is_owned) {
26233         ret_ref |= 1;
26234 }
26235         return ret_ref;
26236 }
26237 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
26238         LDKInit arg_conv;
26239         arg_conv.inner = (void*)(arg & (~1));
26240         arg_conv.is_owned = false;
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26242         uint32_t ret_val = Init_clone_ptr(&arg_conv);
26243         return ret_val;
26244 }
26245
26246 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
26247         LDKInit orig_conv;
26248         orig_conv.inner = (void*)(orig & (~1));
26249         orig_conv.is_owned = false;
26250         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26251         LDKInit ret_var = Init_clone(&orig_conv);
26252         uint32_t ret_ref = 0;
26253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26256         ret_ref = (uintptr_t)ret_var.inner;
26257         if (ret_var.is_owned) {
26258                 ret_ref |= 1;
26259         }
26260         return ret_ref;
26261 }
26262
26263 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
26264         LDKErrorMessage this_obj_conv;
26265         this_obj_conv.inner = (void*)(this_obj & (~1));
26266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26268         ErrorMessage_free(this_obj_conv);
26269 }
26270
26271 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
26272         LDKErrorMessage this_ptr_conv;
26273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26274         this_ptr_conv.is_owned = false;
26275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26276         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26277         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
26278         return ret_arr;
26279 }
26280
26281 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26282         LDKErrorMessage this_ptr_conv;
26283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26284         this_ptr_conv.is_owned = false;
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26286         LDKThirtyTwoBytes val_ref;
26287         CHECK(val->arr_len == 32);
26288         memcpy(val_ref.data, val->elems, 32); FREE(val);
26289         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
26290 }
26291
26292 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
26293         LDKErrorMessage this_ptr_conv;
26294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26295         this_ptr_conv.is_owned = false;
26296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26297         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
26298         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26299         Str_free(ret_str);
26300         return ret_conv;
26301 }
26302
26303 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
26304         LDKErrorMessage this_ptr_conv;
26305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26306         this_ptr_conv.is_owned = false;
26307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26308         LDKStr val_conv = str_ref_to_owned_c(val);
26309         ErrorMessage_set_data(&this_ptr_conv, val_conv);
26310 }
26311
26312 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26313         LDKThirtyTwoBytes channel_id_arg_ref;
26314         CHECK(channel_id_arg->arr_len == 32);
26315         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26316         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26317         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
26318         uint32_t ret_ref = 0;
26319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26322         ret_ref = (uintptr_t)ret_var.inner;
26323         if (ret_var.is_owned) {
26324                 ret_ref |= 1;
26325         }
26326         return ret_ref;
26327 }
26328
26329 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
26330         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
26331 uint32_t ret_ref = 0;
26332 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26333 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26335 ret_ref = (uintptr_t)ret_var.inner;
26336 if (ret_var.is_owned) {
26337         ret_ref |= 1;
26338 }
26339         return ret_ref;
26340 }
26341 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
26342         LDKErrorMessage arg_conv;
26343         arg_conv.inner = (void*)(arg & (~1));
26344         arg_conv.is_owned = false;
26345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26346         uint32_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
26347         return ret_val;
26348 }
26349
26350 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
26351         LDKErrorMessage orig_conv;
26352         orig_conv.inner = (void*)(orig & (~1));
26353         orig_conv.is_owned = false;
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26355         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
26356         uint32_t ret_ref = 0;
26357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26360         ret_ref = (uintptr_t)ret_var.inner;
26361         if (ret_var.is_owned) {
26362                 ret_ref |= 1;
26363         }
26364         return ret_ref;
26365 }
26366
26367 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
26368         LDKWarningMessage this_obj_conv;
26369         this_obj_conv.inner = (void*)(this_obj & (~1));
26370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26372         WarningMessage_free(this_obj_conv);
26373 }
26374
26375 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
26376         LDKWarningMessage this_ptr_conv;
26377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26378         this_ptr_conv.is_owned = false;
26379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26380         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26381         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
26382         return ret_arr;
26383 }
26384
26385 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26386         LDKWarningMessage 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         LDKThirtyTwoBytes val_ref;
26391         CHECK(val->arr_len == 32);
26392         memcpy(val_ref.data, val->elems, 32); FREE(val);
26393         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
26394 }
26395
26396 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
26397         LDKWarningMessage this_ptr_conv;
26398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26399         this_ptr_conv.is_owned = false;
26400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26401         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
26402         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26403         Str_free(ret_str);
26404         return ret_conv;
26405 }
26406
26407 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
26408         LDKWarningMessage this_ptr_conv;
26409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26410         this_ptr_conv.is_owned = false;
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26412         LDKStr val_conv = str_ref_to_owned_c(val);
26413         WarningMessage_set_data(&this_ptr_conv, val_conv);
26414 }
26415
26416 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26417         LDKThirtyTwoBytes channel_id_arg_ref;
26418         CHECK(channel_id_arg->arr_len == 32);
26419         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26420         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26421         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
26422         uint32_t ret_ref = 0;
26423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26426         ret_ref = (uintptr_t)ret_var.inner;
26427         if (ret_var.is_owned) {
26428                 ret_ref |= 1;
26429         }
26430         return ret_ref;
26431 }
26432
26433 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
26434         LDKWarningMessage ret_var = WarningMessage_clone(arg);
26435 uint32_t ret_ref = 0;
26436 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26437 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26438 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26439 ret_ref = (uintptr_t)ret_var.inner;
26440 if (ret_var.is_owned) {
26441         ret_ref |= 1;
26442 }
26443         return ret_ref;
26444 }
26445 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
26446         LDKWarningMessage arg_conv;
26447         arg_conv.inner = (void*)(arg & (~1));
26448         arg_conv.is_owned = false;
26449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26450         uint32_t ret_val = WarningMessage_clone_ptr(&arg_conv);
26451         return ret_val;
26452 }
26453
26454 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
26455         LDKWarningMessage orig_conv;
26456         orig_conv.inner = (void*)(orig & (~1));
26457         orig_conv.is_owned = false;
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26459         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
26460         uint32_t ret_ref = 0;
26461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26464         ret_ref = (uintptr_t)ret_var.inner;
26465         if (ret_var.is_owned) {
26466                 ret_ref |= 1;
26467         }
26468         return ret_ref;
26469 }
26470
26471 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
26472         LDKPing this_obj_conv;
26473         this_obj_conv.inner = (void*)(this_obj & (~1));
26474         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26476         Ping_free(this_obj_conv);
26477 }
26478
26479 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
26480         LDKPing this_ptr_conv;
26481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26482         this_ptr_conv.is_owned = false;
26483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26484         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
26485         return ret_val;
26486 }
26487
26488 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
26489         LDKPing this_ptr_conv;
26490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26491         this_ptr_conv.is_owned = false;
26492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26493         Ping_set_ponglen(&this_ptr_conv, val);
26494 }
26495
26496 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
26497         LDKPing this_ptr_conv;
26498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26499         this_ptr_conv.is_owned = false;
26500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26501         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
26502         return ret_val;
26503 }
26504
26505 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
26506         LDKPing this_ptr_conv;
26507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26508         this_ptr_conv.is_owned = false;
26509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26510         Ping_set_byteslen(&this_ptr_conv, val);
26511 }
26512
26513 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
26514         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26515         uint32_t ret_ref = 0;
26516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26519         ret_ref = (uintptr_t)ret_var.inner;
26520         if (ret_var.is_owned) {
26521                 ret_ref |= 1;
26522         }
26523         return ret_ref;
26524 }
26525
26526 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26527         LDKPing ret_var = Ping_clone(arg);
26528 uint32_t ret_ref = 0;
26529 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26530 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26531 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26532 ret_ref = (uintptr_t)ret_var.inner;
26533 if (ret_var.is_owned) {
26534         ret_ref |= 1;
26535 }
26536         return ret_ref;
26537 }
26538 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26539         LDKPing arg_conv;
26540         arg_conv.inner = (void*)(arg & (~1));
26541         arg_conv.is_owned = false;
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26543         uint32_t ret_val = Ping_clone_ptr(&arg_conv);
26544         return ret_val;
26545 }
26546
26547 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26548         LDKPing orig_conv;
26549         orig_conv.inner = (void*)(orig & (~1));
26550         orig_conv.is_owned = false;
26551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26552         LDKPing ret_var = Ping_clone(&orig_conv);
26553         uint32_t ret_ref = 0;
26554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26557         ret_ref = (uintptr_t)ret_var.inner;
26558         if (ret_var.is_owned) {
26559                 ret_ref |= 1;
26560         }
26561         return ret_ref;
26562 }
26563
26564 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26565         LDKPong this_obj_conv;
26566         this_obj_conv.inner = (void*)(this_obj & (~1));
26567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26569         Pong_free(this_obj_conv);
26570 }
26571
26572 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26573         LDKPong this_ptr_conv;
26574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26575         this_ptr_conv.is_owned = false;
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26577         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26578         return ret_val;
26579 }
26580
26581 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26582         LDKPong this_ptr_conv;
26583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26584         this_ptr_conv.is_owned = false;
26585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26586         Pong_set_byteslen(&this_ptr_conv, val);
26587 }
26588
26589 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26590         LDKPong ret_var = Pong_new(byteslen_arg);
26591         uint32_t ret_ref = 0;
26592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26595         ret_ref = (uintptr_t)ret_var.inner;
26596         if (ret_var.is_owned) {
26597                 ret_ref |= 1;
26598         }
26599         return ret_ref;
26600 }
26601
26602 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26603         LDKPong ret_var = Pong_clone(arg);
26604 uint32_t ret_ref = 0;
26605 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26606 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26607 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26608 ret_ref = (uintptr_t)ret_var.inner;
26609 if (ret_var.is_owned) {
26610         ret_ref |= 1;
26611 }
26612         return ret_ref;
26613 }
26614 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26615         LDKPong arg_conv;
26616         arg_conv.inner = (void*)(arg & (~1));
26617         arg_conv.is_owned = false;
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26619         uint32_t ret_val = Pong_clone_ptr(&arg_conv);
26620         return ret_val;
26621 }
26622
26623 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26624         LDKPong orig_conv;
26625         orig_conv.inner = (void*)(orig & (~1));
26626         orig_conv.is_owned = false;
26627         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26628         LDKPong ret_var = Pong_clone(&orig_conv);
26629         uint32_t ret_ref = 0;
26630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26633         ret_ref = (uintptr_t)ret_var.inner;
26634         if (ret_var.is_owned) {
26635                 ret_ref |= 1;
26636         }
26637         return ret_ref;
26638 }
26639
26640 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26641         LDKOpenChannel this_obj_conv;
26642         this_obj_conv.inner = (void*)(this_obj & (~1));
26643         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26645         OpenChannel_free(this_obj_conv);
26646 }
26647
26648 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26649         LDKOpenChannel this_ptr_conv;
26650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26651         this_ptr_conv.is_owned = false;
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26653         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26654         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26655         return ret_arr;
26656 }
26657
26658 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26659         LDKOpenChannel this_ptr_conv;
26660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26661         this_ptr_conv.is_owned = false;
26662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26663         LDKThirtyTwoBytes val_ref;
26664         CHECK(val->arr_len == 32);
26665         memcpy(val_ref.data, val->elems, 32); FREE(val);
26666         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26667 }
26668
26669 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26670         LDKOpenChannel this_ptr_conv;
26671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26672         this_ptr_conv.is_owned = false;
26673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26674         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26675         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26676         return ret_arr;
26677 }
26678
26679 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26680         LDKOpenChannel this_ptr_conv;
26681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26682         this_ptr_conv.is_owned = false;
26683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26684         LDKThirtyTwoBytes val_ref;
26685         CHECK(val->arr_len == 32);
26686         memcpy(val_ref.data, val->elems, 32); FREE(val);
26687         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26688 }
26689
26690 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26691         LDKOpenChannel this_ptr_conv;
26692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26693         this_ptr_conv.is_owned = false;
26694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26695         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26696         return ret_val;
26697 }
26698
26699 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26700         LDKOpenChannel this_ptr_conv;
26701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26702         this_ptr_conv.is_owned = false;
26703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26704         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26705 }
26706
26707 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26708         LDKOpenChannel this_ptr_conv;
26709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26710         this_ptr_conv.is_owned = false;
26711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26712         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26713         return ret_val;
26714 }
26715
26716 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26717         LDKOpenChannel this_ptr_conv;
26718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26719         this_ptr_conv.is_owned = false;
26720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26721         OpenChannel_set_push_msat(&this_ptr_conv, val);
26722 }
26723
26724 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26725         LDKOpenChannel this_ptr_conv;
26726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26727         this_ptr_conv.is_owned = false;
26728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26729         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26730         return ret_val;
26731 }
26732
26733 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26734         LDKOpenChannel this_ptr_conv;
26735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26736         this_ptr_conv.is_owned = false;
26737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26738         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26739 }
26740
26741 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) {
26742         LDKOpenChannel this_ptr_conv;
26743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26744         this_ptr_conv.is_owned = false;
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26746         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26747         return ret_val;
26748 }
26749
26750 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) {
26751         LDKOpenChannel this_ptr_conv;
26752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26753         this_ptr_conv.is_owned = false;
26754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26755         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26756 }
26757
26758 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26759         LDKOpenChannel this_ptr_conv;
26760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26761         this_ptr_conv.is_owned = false;
26762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26763         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26764         return ret_val;
26765 }
26766
26767 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26768         LDKOpenChannel 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         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26773 }
26774
26775 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26776         LDKOpenChannel this_ptr_conv;
26777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26778         this_ptr_conv.is_owned = false;
26779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26780         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26781         return ret_val;
26782 }
26783
26784 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26785         LDKOpenChannel this_ptr_conv;
26786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26787         this_ptr_conv.is_owned = false;
26788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26789         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26790 }
26791
26792 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26793         LDKOpenChannel this_ptr_conv;
26794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26795         this_ptr_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26797         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26798         return ret_val;
26799 }
26800
26801 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26802         LDKOpenChannel this_ptr_conv;
26803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26804         this_ptr_conv.is_owned = false;
26805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26806         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26807 }
26808
26809 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26810         LDKOpenChannel this_ptr_conv;
26811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26812         this_ptr_conv.is_owned = false;
26813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26814         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26815         return ret_val;
26816 }
26817
26818 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26819         LDKOpenChannel this_ptr_conv;
26820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26821         this_ptr_conv.is_owned = false;
26822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26823         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26824 }
26825
26826 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26827         LDKOpenChannel this_ptr_conv;
26828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26829         this_ptr_conv.is_owned = false;
26830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26831         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26832         return ret_val;
26833 }
26834
26835 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26836         LDKOpenChannel this_ptr_conv;
26837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26838         this_ptr_conv.is_owned = false;
26839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26840         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26841 }
26842
26843 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26844         LDKOpenChannel this_ptr_conv;
26845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26846         this_ptr_conv.is_owned = false;
26847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26848         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26849         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26850         return ret_arr;
26851 }
26852
26853 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26854         LDKOpenChannel this_ptr_conv;
26855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26856         this_ptr_conv.is_owned = false;
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26858         LDKPublicKey val_ref;
26859         CHECK(val->arr_len == 33);
26860         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26861         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26862 }
26863
26864 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26865         LDKOpenChannel this_ptr_conv;
26866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26867         this_ptr_conv.is_owned = false;
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26869         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26870         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26871         return ret_arr;
26872 }
26873
26874 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26875         LDKOpenChannel this_ptr_conv;
26876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26877         this_ptr_conv.is_owned = false;
26878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26879         LDKPublicKey val_ref;
26880         CHECK(val->arr_len == 33);
26881         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26882         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26883 }
26884
26885 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26886         LDKOpenChannel this_ptr_conv;
26887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26888         this_ptr_conv.is_owned = false;
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26890         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26891         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26892         return ret_arr;
26893 }
26894
26895 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26896         LDKOpenChannel this_ptr_conv;
26897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26898         this_ptr_conv.is_owned = false;
26899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26900         LDKPublicKey val_ref;
26901         CHECK(val->arr_len == 33);
26902         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26903         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26904 }
26905
26906 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26907         LDKOpenChannel this_ptr_conv;
26908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26909         this_ptr_conv.is_owned = false;
26910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26911         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26912         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26913         return ret_arr;
26914 }
26915
26916 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26917         LDKOpenChannel this_ptr_conv;
26918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26919         this_ptr_conv.is_owned = false;
26920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26921         LDKPublicKey val_ref;
26922         CHECK(val->arr_len == 33);
26923         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26924         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26925 }
26926
26927 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26928         LDKOpenChannel this_ptr_conv;
26929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26930         this_ptr_conv.is_owned = false;
26931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26932         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26933         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26934         return ret_arr;
26935 }
26936
26937 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26938         LDKOpenChannel this_ptr_conv;
26939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26940         this_ptr_conv.is_owned = false;
26941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26942         LDKPublicKey val_ref;
26943         CHECK(val->arr_len == 33);
26944         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26945         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26946 }
26947
26948 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
26949         LDKOpenChannel this_ptr_conv;
26950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26951         this_ptr_conv.is_owned = false;
26952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26953         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26954         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26955         return ret_arr;
26956 }
26957
26958 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) {
26959         LDKOpenChannel this_ptr_conv;
26960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26961         this_ptr_conv.is_owned = false;
26962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26963         LDKPublicKey val_ref;
26964         CHECK(val->arr_len == 33);
26965         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26966         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26967 }
26968
26969 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
26970         LDKOpenChannel 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         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26975         return ret_val;
26976 }
26977
26978 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
26979         LDKOpenChannel this_ptr_conv;
26980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26981         this_ptr_conv.is_owned = false;
26982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26983         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26984 }
26985
26986 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
26987         LDKOpenChannel this_ptr_conv;
26988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26989         this_ptr_conv.is_owned = false;
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26991         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26992         uint32_t ret_ref = 0;
26993         if ((uintptr_t)ret_var.inner > 4096) {
26994                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26995                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26997                 ret_ref = (uintptr_t)ret_var.inner;
26998                 if (ret_var.is_owned) {
26999                         ret_ref |= 1;
27000                 }
27001         }
27002         return ret_ref;
27003 }
27004
27005 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27006         LDKOpenChannel this_ptr_conv;
27007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27008         this_ptr_conv.is_owned = false;
27009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27010         LDKChannelTypeFeatures val_conv;
27011         val_conv.inner = (void*)(val & (~1));
27012         val_conv.is_owned = (val & 1) || (val == 0);
27013         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27014         val_conv = ChannelTypeFeatures_clone(&val_conv);
27015         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
27016 }
27017
27018 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
27019         LDKOpenChannel ret_var = OpenChannel_clone(arg);
27020 uint32_t ret_ref = 0;
27021 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27022 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27023 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27024 ret_ref = (uintptr_t)ret_var.inner;
27025 if (ret_var.is_owned) {
27026         ret_ref |= 1;
27027 }
27028         return ret_ref;
27029 }
27030 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
27031         LDKOpenChannel arg_conv;
27032         arg_conv.inner = (void*)(arg & (~1));
27033         arg_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27035         uint32_t ret_val = OpenChannel_clone_ptr(&arg_conv);
27036         return ret_val;
27037 }
27038
27039 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
27040         LDKOpenChannel orig_conv;
27041         orig_conv.inner = (void*)(orig & (~1));
27042         orig_conv.is_owned = false;
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27044         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
27045         uint32_t ret_ref = 0;
27046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27049         ret_ref = (uintptr_t)ret_var.inner;
27050         if (ret_var.is_owned) {
27051                 ret_ref |= 1;
27052         }
27053         return ret_ref;
27054 }
27055
27056 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
27057         LDKAcceptChannel this_obj_conv;
27058         this_obj_conv.inner = (void*)(this_obj & (~1));
27059         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27061         AcceptChannel_free(this_obj_conv);
27062 }
27063
27064 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
27065         LDKAcceptChannel this_ptr_conv;
27066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27067         this_ptr_conv.is_owned = false;
27068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27069         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27070         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
27071         return ret_arr;
27072 }
27073
27074 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27075         LDKAcceptChannel this_ptr_conv;
27076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27077         this_ptr_conv.is_owned = false;
27078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27079         LDKThirtyTwoBytes val_ref;
27080         CHECK(val->arr_len == 32);
27081         memcpy(val_ref.data, val->elems, 32); FREE(val);
27082         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
27083 }
27084
27085 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
27086         LDKAcceptChannel this_ptr_conv;
27087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27088         this_ptr_conv.is_owned = false;
27089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27090         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
27091         return ret_val;
27092 }
27093
27094 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
27095         LDKAcceptChannel this_ptr_conv;
27096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27097         this_ptr_conv.is_owned = false;
27098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27099         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
27100 }
27101
27102 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) {
27103         LDKAcceptChannel this_ptr_conv;
27104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27105         this_ptr_conv.is_owned = false;
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27107         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
27108         return ret_val;
27109 }
27110
27111 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) {
27112         LDKAcceptChannel this_ptr_conv;
27113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27114         this_ptr_conv.is_owned = false;
27115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27116         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27117 }
27118
27119 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
27120         LDKAcceptChannel this_ptr_conv;
27121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27122         this_ptr_conv.is_owned = false;
27123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27124         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
27125         return ret_val;
27126 }
27127
27128 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
27129         LDKAcceptChannel this_ptr_conv;
27130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27131         this_ptr_conv.is_owned = false;
27132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27133         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
27134 }
27135
27136 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
27137         LDKAcceptChannel this_ptr_conv;
27138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27139         this_ptr_conv.is_owned = false;
27140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27141         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
27142         return ret_val;
27143 }
27144
27145 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
27146         LDKAcceptChannel this_ptr_conv;
27147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27148         this_ptr_conv.is_owned = false;
27149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27150         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27151 }
27152
27153 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
27154         LDKAcceptChannel this_ptr_conv;
27155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27156         this_ptr_conv.is_owned = false;
27157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27158         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
27159         return ret_val;
27160 }
27161
27162 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
27163         LDKAcceptChannel 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         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
27168 }
27169
27170 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
27171         LDKAcceptChannel this_ptr_conv;
27172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27173         this_ptr_conv.is_owned = false;
27174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27175         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
27176         return ret_val;
27177 }
27178
27179 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
27180         LDKAcceptChannel this_ptr_conv;
27181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27182         this_ptr_conv.is_owned = false;
27183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27184         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
27185 }
27186
27187 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
27188         LDKAcceptChannel this_ptr_conv;
27189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27190         this_ptr_conv.is_owned = false;
27191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27192         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
27193         return ret_val;
27194 }
27195
27196 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
27197         LDKAcceptChannel this_ptr_conv;
27198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27199         this_ptr_conv.is_owned = false;
27200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27201         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27202 }
27203
27204 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
27205         LDKAcceptChannel this_ptr_conv;
27206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27207         this_ptr_conv.is_owned = false;
27208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27209         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27210         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
27211         return ret_arr;
27212 }
27213
27214 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
27215         LDKAcceptChannel this_ptr_conv;
27216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27217         this_ptr_conv.is_owned = false;
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27219         LDKPublicKey val_ref;
27220         CHECK(val->arr_len == 33);
27221         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27222         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27223 }
27224
27225 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
27226         LDKAcceptChannel this_ptr_conv;
27227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27228         this_ptr_conv.is_owned = false;
27229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27230         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27231         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
27232         return ret_arr;
27233 }
27234
27235 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
27236         LDKAcceptChannel this_ptr_conv;
27237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27238         this_ptr_conv.is_owned = false;
27239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27240         LDKPublicKey val_ref;
27241         CHECK(val->arr_len == 33);
27242         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27243         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27244 }
27245
27246 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
27247         LDKAcceptChannel this_ptr_conv;
27248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27249         this_ptr_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27251         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27252         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
27253         return ret_arr;
27254 }
27255
27256 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
27257         LDKAcceptChannel this_ptr_conv;
27258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27259         this_ptr_conv.is_owned = false;
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27261         LDKPublicKey val_ref;
27262         CHECK(val->arr_len == 33);
27263         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27264         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
27265 }
27266
27267 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
27268         LDKAcceptChannel this_ptr_conv;
27269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27270         this_ptr_conv.is_owned = false;
27271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27272         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27273         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
27274         return ret_arr;
27275 }
27276
27277 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
27278         LDKAcceptChannel this_ptr_conv;
27279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27280         this_ptr_conv.is_owned = false;
27281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27282         LDKPublicKey val_ref;
27283         CHECK(val->arr_len == 33);
27284         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27285         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27286 }
27287
27288 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
27289         LDKAcceptChannel this_ptr_conv;
27290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27291         this_ptr_conv.is_owned = false;
27292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27293         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27294         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
27295         return ret_arr;
27296 }
27297
27298 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
27299         LDKAcceptChannel this_ptr_conv;
27300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27301         this_ptr_conv.is_owned = false;
27302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27303         LDKPublicKey val_ref;
27304         CHECK(val->arr_len == 33);
27305         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27306         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27307 }
27308
27309 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27310         LDKAcceptChannel this_ptr_conv;
27311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27312         this_ptr_conv.is_owned = false;
27313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27315         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27316         return ret_arr;
27317 }
27318
27319 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) {
27320         LDKAcceptChannel this_ptr_conv;
27321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27322         this_ptr_conv.is_owned = false;
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27324         LDKPublicKey val_ref;
27325         CHECK(val->arr_len == 33);
27326         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27327         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27328 }
27329
27330 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
27331         LDKAcceptChannel this_ptr_conv;
27332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27333         this_ptr_conv.is_owned = false;
27334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27335         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
27336         uint32_t ret_ref = 0;
27337         if ((uintptr_t)ret_var.inner > 4096) {
27338                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27339                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27341                 ret_ref = (uintptr_t)ret_var.inner;
27342                 if (ret_var.is_owned) {
27343                         ret_ref |= 1;
27344                 }
27345         }
27346         return ret_ref;
27347 }
27348
27349 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27350         LDKAcceptChannel this_ptr_conv;
27351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27352         this_ptr_conv.is_owned = false;
27353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27354         LDKChannelTypeFeatures val_conv;
27355         val_conv.inner = (void*)(val & (~1));
27356         val_conv.is_owned = (val & 1) || (val == 0);
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27358         val_conv = ChannelTypeFeatures_clone(&val_conv);
27359         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
27360 }
27361
27362 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
27363         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
27364 uint32_t ret_ref = 0;
27365 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27366 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27367 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27368 ret_ref = (uintptr_t)ret_var.inner;
27369 if (ret_var.is_owned) {
27370         ret_ref |= 1;
27371 }
27372         return ret_ref;
27373 }
27374 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
27375         LDKAcceptChannel arg_conv;
27376         arg_conv.inner = (void*)(arg & (~1));
27377         arg_conv.is_owned = false;
27378         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27379         uint32_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
27380         return ret_val;
27381 }
27382
27383 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
27384         LDKAcceptChannel orig_conv;
27385         orig_conv.inner = (void*)(orig & (~1));
27386         orig_conv.is_owned = false;
27387         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27388         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
27389         uint32_t ret_ref = 0;
27390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27393         ret_ref = (uintptr_t)ret_var.inner;
27394         if (ret_var.is_owned) {
27395                 ret_ref |= 1;
27396         }
27397         return ret_ref;
27398 }
27399
27400 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
27401         LDKFundingCreated this_obj_conv;
27402         this_obj_conv.inner = (void*)(this_obj & (~1));
27403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27405         FundingCreated_free(this_obj_conv);
27406 }
27407
27408 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
27409         LDKFundingCreated 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27414         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
27415         return ret_arr;
27416 }
27417
27418 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27419         LDKFundingCreated this_ptr_conv;
27420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27421         this_ptr_conv.is_owned = false;
27422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27423         LDKThirtyTwoBytes val_ref;
27424         CHECK(val->arr_len == 32);
27425         memcpy(val_ref.data, val->elems, 32); FREE(val);
27426         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27427 }
27428
27429 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
27430         LDKFundingCreated this_ptr_conv;
27431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27432         this_ptr_conv.is_owned = false;
27433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27434         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27435         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
27436         return ret_arr;
27437 }
27438
27439 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
27440         LDKFundingCreated this_ptr_conv;
27441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27442         this_ptr_conv.is_owned = false;
27443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27444         LDKThirtyTwoBytes val_ref;
27445         CHECK(val->arr_len == 32);
27446         memcpy(val_ref.data, val->elems, 32); FREE(val);
27447         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27448 }
27449
27450 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
27451         LDKFundingCreated this_ptr_conv;
27452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27453         this_ptr_conv.is_owned = false;
27454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27455         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
27456         return ret_val;
27457 }
27458
27459 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
27460         LDKFundingCreated this_ptr_conv;
27461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27462         this_ptr_conv.is_owned = false;
27463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27464         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27465 }
27466
27467 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
27468         LDKFundingCreated this_ptr_conv;
27469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27470         this_ptr_conv.is_owned = false;
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27473         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
27474         return ret_arr;
27475 }
27476
27477 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
27478         LDKFundingCreated 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         LDKSignature val_ref;
27483         CHECK(val->arr_len == 64);
27484         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27485         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27486 }
27487
27488 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) {
27489         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27490         CHECK(temporary_channel_id_arg->arr_len == 32);
27491         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
27492         LDKThirtyTwoBytes funding_txid_arg_ref;
27493         CHECK(funding_txid_arg->arr_len == 32);
27494         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
27495         LDKSignature signature_arg_ref;
27496         CHECK(signature_arg->arr_len == 64);
27497         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27498         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27499         uint32_t ret_ref = 0;
27500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27503         ret_ref = (uintptr_t)ret_var.inner;
27504         if (ret_var.is_owned) {
27505                 ret_ref |= 1;
27506         }
27507         return ret_ref;
27508 }
27509
27510 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27511         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27512 uint32_t ret_ref = 0;
27513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27516 ret_ref = (uintptr_t)ret_var.inner;
27517 if (ret_var.is_owned) {
27518         ret_ref |= 1;
27519 }
27520         return ret_ref;
27521 }
27522 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
27523         LDKFundingCreated arg_conv;
27524         arg_conv.inner = (void*)(arg & (~1));
27525         arg_conv.is_owned = false;
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27527         uint32_t ret_val = FundingCreated_clone_ptr(&arg_conv);
27528         return ret_val;
27529 }
27530
27531 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
27532         LDKFundingCreated orig_conv;
27533         orig_conv.inner = (void*)(orig & (~1));
27534         orig_conv.is_owned = false;
27535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27536         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27537         uint32_t ret_ref = 0;
27538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27541         ret_ref = (uintptr_t)ret_var.inner;
27542         if (ret_var.is_owned) {
27543                 ret_ref |= 1;
27544         }
27545         return ret_ref;
27546 }
27547
27548 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27549         LDKFundingSigned this_obj_conv;
27550         this_obj_conv.inner = (void*)(this_obj & (~1));
27551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27553         FundingSigned_free(this_obj_conv);
27554 }
27555
27556 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27557         LDKFundingSigned this_ptr_conv;
27558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27559         this_ptr_conv.is_owned = false;
27560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27561         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27562         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27563         return ret_arr;
27564 }
27565
27566 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27567         LDKFundingSigned this_ptr_conv;
27568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27569         this_ptr_conv.is_owned = false;
27570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27571         LDKThirtyTwoBytes val_ref;
27572         CHECK(val->arr_len == 32);
27573         memcpy(val_ref.data, val->elems, 32); FREE(val);
27574         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27575 }
27576
27577 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27578         LDKFundingSigned this_ptr_conv;
27579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27580         this_ptr_conv.is_owned = false;
27581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27582         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27583         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27584         return ret_arr;
27585 }
27586
27587 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27588         LDKFundingSigned this_ptr_conv;
27589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27590         this_ptr_conv.is_owned = false;
27591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27592         LDKSignature val_ref;
27593         CHECK(val->arr_len == 64);
27594         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27595         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27596 }
27597
27598 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27599         LDKThirtyTwoBytes channel_id_arg_ref;
27600         CHECK(channel_id_arg->arr_len == 32);
27601         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27602         LDKSignature signature_arg_ref;
27603         CHECK(signature_arg->arr_len == 64);
27604         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27605         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27606         uint32_t ret_ref = 0;
27607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27610         ret_ref = (uintptr_t)ret_var.inner;
27611         if (ret_var.is_owned) {
27612                 ret_ref |= 1;
27613         }
27614         return ret_ref;
27615 }
27616
27617 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27618         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27619 uint32_t ret_ref = 0;
27620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27623 ret_ref = (uintptr_t)ret_var.inner;
27624 if (ret_var.is_owned) {
27625         ret_ref |= 1;
27626 }
27627         return ret_ref;
27628 }
27629 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27630         LDKFundingSigned arg_conv;
27631         arg_conv.inner = (void*)(arg & (~1));
27632         arg_conv.is_owned = false;
27633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27634         uint32_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27635         return ret_val;
27636 }
27637
27638 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27639         LDKFundingSigned orig_conv;
27640         orig_conv.inner = (void*)(orig & (~1));
27641         orig_conv.is_owned = false;
27642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27643         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27644         uint32_t ret_ref = 0;
27645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27648         ret_ref = (uintptr_t)ret_var.inner;
27649         if (ret_var.is_owned) {
27650                 ret_ref |= 1;
27651         }
27652         return ret_ref;
27653 }
27654
27655 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27656         LDKFundingLocked this_obj_conv;
27657         this_obj_conv.inner = (void*)(this_obj & (~1));
27658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27660         FundingLocked_free(this_obj_conv);
27661 }
27662
27663 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27664         LDKFundingLocked this_ptr_conv;
27665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27666         this_ptr_conv.is_owned = false;
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27668         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27669         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27670         return ret_arr;
27671 }
27672
27673 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27674         LDKFundingLocked this_ptr_conv;
27675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27676         this_ptr_conv.is_owned = false;
27677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27678         LDKThirtyTwoBytes val_ref;
27679         CHECK(val->arr_len == 32);
27680         memcpy(val_ref.data, val->elems, 32); FREE(val);
27681         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27682 }
27683
27684 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27685         LDKFundingLocked this_ptr_conv;
27686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27687         this_ptr_conv.is_owned = false;
27688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27689         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27690         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27691         return ret_arr;
27692 }
27693
27694 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) {
27695         LDKFundingLocked this_ptr_conv;
27696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27697         this_ptr_conv.is_owned = false;
27698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27699         LDKPublicKey val_ref;
27700         CHECK(val->arr_len == 33);
27701         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27702         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27703 }
27704
27705 uint32_t  __attribute__((export_name("TS_FundingLocked_get_short_channel_id_alias"))) TS_FundingLocked_get_short_channel_id_alias(uint32_t this_ptr) {
27706         LDKFundingLocked this_ptr_conv;
27707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27708         this_ptr_conv.is_owned = false;
27709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27710         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27711         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
27712         uint32_t ret_ref = (uintptr_t)ret_copy;
27713         return ret_ref;
27714 }
27715
27716 void  __attribute__((export_name("TS_FundingLocked_set_short_channel_id_alias"))) TS_FundingLocked_set_short_channel_id_alias(uint32_t this_ptr, uint32_t val) {
27717         LDKFundingLocked this_ptr_conv;
27718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27719         this_ptr_conv.is_owned = false;
27720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27721         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27722         CHECK_ACCESS(val_ptr);
27723         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27724         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27725         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
27726 }
27727
27728 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, uint32_t short_channel_id_alias_arg) {
27729         LDKThirtyTwoBytes channel_id_arg_ref;
27730         CHECK(channel_id_arg->arr_len == 32);
27731         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27732         LDKPublicKey next_per_commitment_point_arg_ref;
27733         CHECK(next_per_commitment_point_arg->arr_len == 33);
27734         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27735         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
27736         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
27737         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
27738         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
27739         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
27740         uint32_t ret_ref = 0;
27741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27744         ret_ref = (uintptr_t)ret_var.inner;
27745         if (ret_var.is_owned) {
27746                 ret_ref |= 1;
27747         }
27748         return ret_ref;
27749 }
27750
27751 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27752         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27753 uint32_t ret_ref = 0;
27754 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27755 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27756 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27757 ret_ref = (uintptr_t)ret_var.inner;
27758 if (ret_var.is_owned) {
27759         ret_ref |= 1;
27760 }
27761         return ret_ref;
27762 }
27763 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27764         LDKFundingLocked arg_conv;
27765         arg_conv.inner = (void*)(arg & (~1));
27766         arg_conv.is_owned = false;
27767         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27768         uint32_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27769         return ret_val;
27770 }
27771
27772 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27773         LDKFundingLocked orig_conv;
27774         orig_conv.inner = (void*)(orig & (~1));
27775         orig_conv.is_owned = false;
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27777         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27778         uint32_t ret_ref = 0;
27779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27782         ret_ref = (uintptr_t)ret_var.inner;
27783         if (ret_var.is_owned) {
27784                 ret_ref |= 1;
27785         }
27786         return ret_ref;
27787 }
27788
27789 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27790         LDKShutdown this_obj_conv;
27791         this_obj_conv.inner = (void*)(this_obj & (~1));
27792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27794         Shutdown_free(this_obj_conv);
27795 }
27796
27797 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27798         LDKShutdown this_ptr_conv;
27799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27800         this_ptr_conv.is_owned = false;
27801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27802         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27803         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27804         return ret_arr;
27805 }
27806
27807 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27808         LDKShutdown this_ptr_conv;
27809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27810         this_ptr_conv.is_owned = false;
27811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27812         LDKThirtyTwoBytes val_ref;
27813         CHECK(val->arr_len == 32);
27814         memcpy(val_ref.data, val->elems, 32); FREE(val);
27815         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27816 }
27817
27818 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27819         LDKShutdown this_ptr_conv;
27820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27821         this_ptr_conv.is_owned = false;
27822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27823         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27824         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27825         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27826         return ret_arr;
27827 }
27828
27829 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27830         LDKShutdown this_ptr_conv;
27831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27832         this_ptr_conv.is_owned = false;
27833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27834         LDKCVec_u8Z val_ref;
27835         val_ref.datalen = val->arr_len;
27836         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27837         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27838         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27839 }
27840
27841 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27842         LDKThirtyTwoBytes channel_id_arg_ref;
27843         CHECK(channel_id_arg->arr_len == 32);
27844         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27845         LDKCVec_u8Z scriptpubkey_arg_ref;
27846         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27847         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27848         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27849         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27850         uint32_t ret_ref = 0;
27851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27854         ret_ref = (uintptr_t)ret_var.inner;
27855         if (ret_var.is_owned) {
27856                 ret_ref |= 1;
27857         }
27858         return ret_ref;
27859 }
27860
27861 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27862         LDKShutdown ret_var = Shutdown_clone(arg);
27863 uint32_t ret_ref = 0;
27864 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27865 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27866 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27867 ret_ref = (uintptr_t)ret_var.inner;
27868 if (ret_var.is_owned) {
27869         ret_ref |= 1;
27870 }
27871         return ret_ref;
27872 }
27873 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27874         LDKShutdown arg_conv;
27875         arg_conv.inner = (void*)(arg & (~1));
27876         arg_conv.is_owned = false;
27877         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27878         uint32_t ret_val = Shutdown_clone_ptr(&arg_conv);
27879         return ret_val;
27880 }
27881
27882 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27883         LDKShutdown orig_conv;
27884         orig_conv.inner = (void*)(orig & (~1));
27885         orig_conv.is_owned = false;
27886         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27887         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27888         uint32_t ret_ref = 0;
27889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27892         ret_ref = (uintptr_t)ret_var.inner;
27893         if (ret_var.is_owned) {
27894                 ret_ref |= 1;
27895         }
27896         return ret_ref;
27897 }
27898
27899 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27900         LDKClosingSignedFeeRange this_obj_conv;
27901         this_obj_conv.inner = (void*)(this_obj & (~1));
27902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27904         ClosingSignedFeeRange_free(this_obj_conv);
27905 }
27906
27907 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27908         LDKClosingSignedFeeRange this_ptr_conv;
27909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27910         this_ptr_conv.is_owned = false;
27911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27912         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27913         return ret_val;
27914 }
27915
27916 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27917         LDKClosingSignedFeeRange this_ptr_conv;
27918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27919         this_ptr_conv.is_owned = false;
27920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27921         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27922 }
27923
27924 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27925         LDKClosingSignedFeeRange this_ptr_conv;
27926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27927         this_ptr_conv.is_owned = false;
27928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27929         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27930         return ret_val;
27931 }
27932
27933 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27934         LDKClosingSignedFeeRange this_ptr_conv;
27935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27936         this_ptr_conv.is_owned = false;
27937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27938         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27939 }
27940
27941 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
27942         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27943         uint32_t ret_ref = 0;
27944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27947         ret_ref = (uintptr_t)ret_var.inner;
27948         if (ret_var.is_owned) {
27949                 ret_ref |= 1;
27950         }
27951         return ret_ref;
27952 }
27953
27954 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27955         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
27956 uint32_t ret_ref = 0;
27957 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27958 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27959 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27960 ret_ref = (uintptr_t)ret_var.inner;
27961 if (ret_var.is_owned) {
27962         ret_ref |= 1;
27963 }
27964         return ret_ref;
27965 }
27966 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
27967         LDKClosingSignedFeeRange arg_conv;
27968         arg_conv.inner = (void*)(arg & (~1));
27969         arg_conv.is_owned = false;
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27971         uint32_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27972         return ret_val;
27973 }
27974
27975 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
27976         LDKClosingSignedFeeRange orig_conv;
27977         orig_conv.inner = (void*)(orig & (~1));
27978         orig_conv.is_owned = false;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27980         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27981         uint32_t ret_ref = 0;
27982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27985         ret_ref = (uintptr_t)ret_var.inner;
27986         if (ret_var.is_owned) {
27987                 ret_ref |= 1;
27988         }
27989         return ret_ref;
27990 }
27991
27992 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
27993         LDKClosingSigned this_obj_conv;
27994         this_obj_conv.inner = (void*)(this_obj & (~1));
27995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27997         ClosingSigned_free(this_obj_conv);
27998 }
27999
28000 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
28001         LDKClosingSigned this_ptr_conv;
28002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28003         this_ptr_conv.is_owned = false;
28004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28005         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28006         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
28007         return ret_arr;
28008 }
28009
28010 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28011         LDKClosingSigned this_ptr_conv;
28012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28013         this_ptr_conv.is_owned = false;
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28015         LDKThirtyTwoBytes val_ref;
28016         CHECK(val->arr_len == 32);
28017         memcpy(val_ref.data, val->elems, 32); FREE(val);
28018         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
28019 }
28020
28021 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
28022         LDKClosingSigned this_ptr_conv;
28023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28024         this_ptr_conv.is_owned = false;
28025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28026         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
28027         return ret_val;
28028 }
28029
28030 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
28031         LDKClosingSigned this_ptr_conv;
28032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28033         this_ptr_conv.is_owned = false;
28034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28035         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
28036 }
28037
28038 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
28039         LDKClosingSigned this_ptr_conv;
28040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28041         this_ptr_conv.is_owned = false;
28042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28043         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28044         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28045         return ret_arr;
28046 }
28047
28048 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28049         LDKClosingSigned this_ptr_conv;
28050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28051         this_ptr_conv.is_owned = false;
28052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28053         LDKSignature val_ref;
28054         CHECK(val->arr_len == 64);
28055         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28056         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
28057 }
28058
28059 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
28060         LDKClosingSigned this_ptr_conv;
28061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28062         this_ptr_conv.is_owned = false;
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28064         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
28065         uint32_t ret_ref = 0;
28066         if ((uintptr_t)ret_var.inner > 4096) {
28067                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28068                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28070                 ret_ref = (uintptr_t)ret_var.inner;
28071                 if (ret_var.is_owned) {
28072                         ret_ref |= 1;
28073                 }
28074         }
28075         return ret_ref;
28076 }
28077
28078 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
28079         LDKClosingSigned this_ptr_conv;
28080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28081         this_ptr_conv.is_owned = false;
28082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28083         LDKClosingSignedFeeRange val_conv;
28084         val_conv.inner = (void*)(val & (~1));
28085         val_conv.is_owned = (val & 1) || (val == 0);
28086         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28087         val_conv = ClosingSignedFeeRange_clone(&val_conv);
28088         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
28089 }
28090
28091 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) {
28092         LDKThirtyTwoBytes channel_id_arg_ref;
28093         CHECK(channel_id_arg->arr_len == 32);
28094         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28095         LDKSignature signature_arg_ref;
28096         CHECK(signature_arg->arr_len == 64);
28097         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28098         LDKClosingSignedFeeRange fee_range_arg_conv;
28099         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
28100         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
28101         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
28102         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
28103         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
28104         uint32_t ret_ref = 0;
28105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28108         ret_ref = (uintptr_t)ret_var.inner;
28109         if (ret_var.is_owned) {
28110                 ret_ref |= 1;
28111         }
28112         return ret_ref;
28113 }
28114
28115 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
28116         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
28117 uint32_t ret_ref = 0;
28118 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28119 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28121 ret_ref = (uintptr_t)ret_var.inner;
28122 if (ret_var.is_owned) {
28123         ret_ref |= 1;
28124 }
28125         return ret_ref;
28126 }
28127 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
28128         LDKClosingSigned arg_conv;
28129         arg_conv.inner = (void*)(arg & (~1));
28130         arg_conv.is_owned = false;
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28132         uint32_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
28133         return ret_val;
28134 }
28135
28136 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
28137         LDKClosingSigned orig_conv;
28138         orig_conv.inner = (void*)(orig & (~1));
28139         orig_conv.is_owned = false;
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28141         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
28142         uint32_t ret_ref = 0;
28143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28146         ret_ref = (uintptr_t)ret_var.inner;
28147         if (ret_var.is_owned) {
28148                 ret_ref |= 1;
28149         }
28150         return ret_ref;
28151 }
28152
28153 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
28154         LDKUpdateAddHTLC this_obj_conv;
28155         this_obj_conv.inner = (void*)(this_obj & (~1));
28156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28158         UpdateAddHTLC_free(this_obj_conv);
28159 }
28160
28161 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
28162         LDKUpdateAddHTLC this_ptr_conv;
28163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28164         this_ptr_conv.is_owned = false;
28165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28166         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28167         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
28168         return ret_arr;
28169 }
28170
28171 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28172         LDKUpdateAddHTLC this_ptr_conv;
28173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28174         this_ptr_conv.is_owned = false;
28175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28176         LDKThirtyTwoBytes val_ref;
28177         CHECK(val->arr_len == 32);
28178         memcpy(val_ref.data, val->elems, 32); FREE(val);
28179         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
28180 }
28181
28182 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
28183         LDKUpdateAddHTLC this_ptr_conv;
28184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28185         this_ptr_conv.is_owned = false;
28186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28187         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
28188         return ret_val;
28189 }
28190
28191 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28192         LDKUpdateAddHTLC this_ptr_conv;
28193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28194         this_ptr_conv.is_owned = false;
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28196         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
28197 }
28198
28199 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
28200         LDKUpdateAddHTLC this_ptr_conv;
28201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28202         this_ptr_conv.is_owned = false;
28203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28204         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
28205         return ret_val;
28206 }
28207
28208 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
28209         LDKUpdateAddHTLC this_ptr_conv;
28210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28211         this_ptr_conv.is_owned = false;
28212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28213         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
28214 }
28215
28216 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
28217         LDKUpdateAddHTLC this_ptr_conv;
28218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28219         this_ptr_conv.is_owned = false;
28220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28221         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28222         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
28223         return ret_arr;
28224 }
28225
28226 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
28227         LDKUpdateAddHTLC this_ptr_conv;
28228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28229         this_ptr_conv.is_owned = false;
28230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28231         LDKThirtyTwoBytes val_ref;
28232         CHECK(val->arr_len == 32);
28233         memcpy(val_ref.data, val->elems, 32); FREE(val);
28234         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
28235 }
28236
28237 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
28238         LDKUpdateAddHTLC this_ptr_conv;
28239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28240         this_ptr_conv.is_owned = false;
28241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28242         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
28243         return ret_val;
28244 }
28245
28246 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
28247         LDKUpdateAddHTLC this_ptr_conv;
28248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28249         this_ptr_conv.is_owned = false;
28250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28251         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
28252 }
28253
28254 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
28255         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
28256 uint32_t ret_ref = 0;
28257 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28258 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28259 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28260 ret_ref = (uintptr_t)ret_var.inner;
28261 if (ret_var.is_owned) {
28262         ret_ref |= 1;
28263 }
28264         return ret_ref;
28265 }
28266 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
28267         LDKUpdateAddHTLC arg_conv;
28268         arg_conv.inner = (void*)(arg & (~1));
28269         arg_conv.is_owned = false;
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28271         uint32_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
28272         return ret_val;
28273 }
28274
28275 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
28276         LDKUpdateAddHTLC orig_conv;
28277         orig_conv.inner = (void*)(orig & (~1));
28278         orig_conv.is_owned = false;
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28280         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
28281         uint32_t ret_ref = 0;
28282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28285         ret_ref = (uintptr_t)ret_var.inner;
28286         if (ret_var.is_owned) {
28287                 ret_ref |= 1;
28288         }
28289         return ret_ref;
28290 }
28291
28292 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
28293         LDKUpdateFulfillHTLC this_obj_conv;
28294         this_obj_conv.inner = (void*)(this_obj & (~1));
28295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28297         UpdateFulfillHTLC_free(this_obj_conv);
28298 }
28299
28300 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
28301         LDKUpdateFulfillHTLC this_ptr_conv;
28302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28303         this_ptr_conv.is_owned = false;
28304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28305         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28306         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
28307         return ret_arr;
28308 }
28309
28310 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28311         LDKUpdateFulfillHTLC this_ptr_conv;
28312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28313         this_ptr_conv.is_owned = false;
28314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28315         LDKThirtyTwoBytes val_ref;
28316         CHECK(val->arr_len == 32);
28317         memcpy(val_ref.data, val->elems, 32); FREE(val);
28318         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
28319 }
28320
28321 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
28322         LDKUpdateFulfillHTLC this_ptr_conv;
28323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28324         this_ptr_conv.is_owned = false;
28325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28326         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
28327         return ret_val;
28328 }
28329
28330 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28331         LDKUpdateFulfillHTLC this_ptr_conv;
28332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28333         this_ptr_conv.is_owned = false;
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28335         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
28336 }
28337
28338 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
28339         LDKUpdateFulfillHTLC this_ptr_conv;
28340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28341         this_ptr_conv.is_owned = false;
28342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28343         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28344         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
28345         return ret_arr;
28346 }
28347
28348 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
28349         LDKUpdateFulfillHTLC this_ptr_conv;
28350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28351         this_ptr_conv.is_owned = false;
28352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28353         LDKThirtyTwoBytes val_ref;
28354         CHECK(val->arr_len == 32);
28355         memcpy(val_ref.data, val->elems, 32); FREE(val);
28356         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
28357 }
28358
28359 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) {
28360         LDKThirtyTwoBytes channel_id_arg_ref;
28361         CHECK(channel_id_arg->arr_len == 32);
28362         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28363         LDKThirtyTwoBytes payment_preimage_arg_ref;
28364         CHECK(payment_preimage_arg->arr_len == 32);
28365         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
28366         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
28367         uint32_t ret_ref = 0;
28368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28371         ret_ref = (uintptr_t)ret_var.inner;
28372         if (ret_var.is_owned) {
28373                 ret_ref |= 1;
28374         }
28375         return ret_ref;
28376 }
28377
28378 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
28379         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
28380 uint32_t ret_ref = 0;
28381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28384 ret_ref = (uintptr_t)ret_var.inner;
28385 if (ret_var.is_owned) {
28386         ret_ref |= 1;
28387 }
28388         return ret_ref;
28389 }
28390 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
28391         LDKUpdateFulfillHTLC arg_conv;
28392         arg_conv.inner = (void*)(arg & (~1));
28393         arg_conv.is_owned = false;
28394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28395         uint32_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
28396         return ret_val;
28397 }
28398
28399 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
28400         LDKUpdateFulfillHTLC orig_conv;
28401         orig_conv.inner = (void*)(orig & (~1));
28402         orig_conv.is_owned = false;
28403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28404         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
28405         uint32_t ret_ref = 0;
28406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28409         ret_ref = (uintptr_t)ret_var.inner;
28410         if (ret_var.is_owned) {
28411                 ret_ref |= 1;
28412         }
28413         return ret_ref;
28414 }
28415
28416 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
28417         LDKUpdateFailHTLC this_obj_conv;
28418         this_obj_conv.inner = (void*)(this_obj & (~1));
28419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28421         UpdateFailHTLC_free(this_obj_conv);
28422 }
28423
28424 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
28425         LDKUpdateFailHTLC this_ptr_conv;
28426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28427         this_ptr_conv.is_owned = false;
28428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28429         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28430         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
28431         return ret_arr;
28432 }
28433
28434 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28435         LDKUpdateFailHTLC this_ptr_conv;
28436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28437         this_ptr_conv.is_owned = false;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28439         LDKThirtyTwoBytes val_ref;
28440         CHECK(val->arr_len == 32);
28441         memcpy(val_ref.data, val->elems, 32); FREE(val);
28442         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28443 }
28444
28445 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
28446         LDKUpdateFailHTLC this_ptr_conv;
28447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28448         this_ptr_conv.is_owned = false;
28449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28450         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28451         return ret_val;
28452 }
28453
28454 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28455         LDKUpdateFailHTLC this_ptr_conv;
28456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28457         this_ptr_conv.is_owned = false;
28458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28459         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28460 }
28461
28462 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28463         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28464 uint32_t ret_ref = 0;
28465 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28466 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28467 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28468 ret_ref = (uintptr_t)ret_var.inner;
28469 if (ret_var.is_owned) {
28470         ret_ref |= 1;
28471 }
28472         return ret_ref;
28473 }
28474 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
28475         LDKUpdateFailHTLC arg_conv;
28476         arg_conv.inner = (void*)(arg & (~1));
28477         arg_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28479         uint32_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
28480         return ret_val;
28481 }
28482
28483 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
28484         LDKUpdateFailHTLC orig_conv;
28485         orig_conv.inner = (void*)(orig & (~1));
28486         orig_conv.is_owned = false;
28487         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28488         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28489         uint32_t ret_ref = 0;
28490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28493         ret_ref = (uintptr_t)ret_var.inner;
28494         if (ret_var.is_owned) {
28495                 ret_ref |= 1;
28496         }
28497         return ret_ref;
28498 }
28499
28500 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
28501         LDKUpdateFailMalformedHTLC this_obj_conv;
28502         this_obj_conv.inner = (void*)(this_obj & (~1));
28503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28505         UpdateFailMalformedHTLC_free(this_obj_conv);
28506 }
28507
28508 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
28509         LDKUpdateFailMalformedHTLC this_ptr_conv;
28510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28511         this_ptr_conv.is_owned = false;
28512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28513         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28514         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
28515         return ret_arr;
28516 }
28517
28518 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28519         LDKUpdateFailMalformedHTLC this_ptr_conv;
28520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28521         this_ptr_conv.is_owned = false;
28522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28523         LDKThirtyTwoBytes val_ref;
28524         CHECK(val->arr_len == 32);
28525         memcpy(val_ref.data, val->elems, 32); FREE(val);
28526         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28527 }
28528
28529 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
28530         LDKUpdateFailMalformedHTLC this_ptr_conv;
28531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28532         this_ptr_conv.is_owned = false;
28533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28534         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28535         return ret_val;
28536 }
28537
28538 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28539         LDKUpdateFailMalformedHTLC this_ptr_conv;
28540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28541         this_ptr_conv.is_owned = false;
28542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28543         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28544 }
28545
28546 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
28547         LDKUpdateFailMalformedHTLC this_ptr_conv;
28548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28549         this_ptr_conv.is_owned = false;
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28551         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28552         return ret_val;
28553 }
28554
28555 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
28556         LDKUpdateFailMalformedHTLC this_ptr_conv;
28557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28558         this_ptr_conv.is_owned = false;
28559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28560         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28561 }
28562
28563 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28564         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28565 uint32_t ret_ref = 0;
28566 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28567 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28568 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28569 ret_ref = (uintptr_t)ret_var.inner;
28570 if (ret_var.is_owned) {
28571         ret_ref |= 1;
28572 }
28573         return ret_ref;
28574 }
28575 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28576         LDKUpdateFailMalformedHTLC arg_conv;
28577         arg_conv.inner = (void*)(arg & (~1));
28578         arg_conv.is_owned = false;
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28580         uint32_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28581         return ret_val;
28582 }
28583
28584 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28585         LDKUpdateFailMalformedHTLC orig_conv;
28586         orig_conv.inner = (void*)(orig & (~1));
28587         orig_conv.is_owned = false;
28588         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28589         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28590         uint32_t ret_ref = 0;
28591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28594         ret_ref = (uintptr_t)ret_var.inner;
28595         if (ret_var.is_owned) {
28596                 ret_ref |= 1;
28597         }
28598         return ret_ref;
28599 }
28600
28601 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28602         LDKCommitmentSigned this_obj_conv;
28603         this_obj_conv.inner = (void*)(this_obj & (~1));
28604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28606         CommitmentSigned_free(this_obj_conv);
28607 }
28608
28609 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28610         LDKCommitmentSigned this_ptr_conv;
28611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28612         this_ptr_conv.is_owned = false;
28613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28614         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28615         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28616         return ret_arr;
28617 }
28618
28619 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28620         LDKCommitmentSigned this_ptr_conv;
28621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28622         this_ptr_conv.is_owned = false;
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28624         LDKThirtyTwoBytes val_ref;
28625         CHECK(val->arr_len == 32);
28626         memcpy(val_ref.data, val->elems, 32); FREE(val);
28627         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28628 }
28629
28630 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28631         LDKCommitmentSigned this_ptr_conv;
28632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28633         this_ptr_conv.is_owned = false;
28634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28635         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28636         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28637         return ret_arr;
28638 }
28639
28640 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28641         LDKCommitmentSigned this_ptr_conv;
28642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28643         this_ptr_conv.is_owned = false;
28644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28645         LDKSignature val_ref;
28646         CHECK(val->arr_len == 64);
28647         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28648         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28649 }
28650
28651 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28652         LDKCommitmentSigned this_ptr_conv;
28653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28654         this_ptr_conv.is_owned = false;
28655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28656         LDKCVec_SignatureZ val_constr;
28657         val_constr.datalen = val->arr_len;
28658         if (val_constr.datalen > 0)
28659                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28660         else
28661                 val_constr.data = NULL;
28662         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28663         for (size_t m = 0; m < val_constr.datalen; m++) {
28664                 int8_tArray val_conv_12 = val_vals[m];
28665                 LDKSignature val_conv_12_ref;
28666                 CHECK(val_conv_12->arr_len == 64);
28667                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28668                 val_constr.data[m] = val_conv_12_ref;
28669         }
28670         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28671 }
28672
28673 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28674         LDKThirtyTwoBytes channel_id_arg_ref;
28675         CHECK(channel_id_arg->arr_len == 32);
28676         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28677         LDKSignature signature_arg_ref;
28678         CHECK(signature_arg->arr_len == 64);
28679         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28680         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28681         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28682         if (htlc_signatures_arg_constr.datalen > 0)
28683                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28684         else
28685                 htlc_signatures_arg_constr.data = NULL;
28686         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28687         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28688                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28689                 LDKSignature htlc_signatures_arg_conv_12_ref;
28690                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28691                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28692                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28693         }
28694         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28695         uint32_t ret_ref = 0;
28696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28699         ret_ref = (uintptr_t)ret_var.inner;
28700         if (ret_var.is_owned) {
28701                 ret_ref |= 1;
28702         }
28703         return ret_ref;
28704 }
28705
28706 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28707         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28708 uint32_t ret_ref = 0;
28709 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28710 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28711 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28712 ret_ref = (uintptr_t)ret_var.inner;
28713 if (ret_var.is_owned) {
28714         ret_ref |= 1;
28715 }
28716         return ret_ref;
28717 }
28718 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28719         LDKCommitmentSigned arg_conv;
28720         arg_conv.inner = (void*)(arg & (~1));
28721         arg_conv.is_owned = false;
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28723         uint32_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28724         return ret_val;
28725 }
28726
28727 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28728         LDKCommitmentSigned orig_conv;
28729         orig_conv.inner = (void*)(orig & (~1));
28730         orig_conv.is_owned = false;
28731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28732         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28733         uint32_t ret_ref = 0;
28734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28737         ret_ref = (uintptr_t)ret_var.inner;
28738         if (ret_var.is_owned) {
28739                 ret_ref |= 1;
28740         }
28741         return ret_ref;
28742 }
28743
28744 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28745         LDKRevokeAndACK this_obj_conv;
28746         this_obj_conv.inner = (void*)(this_obj & (~1));
28747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28749         RevokeAndACK_free(this_obj_conv);
28750 }
28751
28752 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28753         LDKRevokeAndACK this_ptr_conv;
28754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28755         this_ptr_conv.is_owned = false;
28756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28757         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28758         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28759         return ret_arr;
28760 }
28761
28762 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28763         LDKRevokeAndACK this_ptr_conv;
28764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28765         this_ptr_conv.is_owned = false;
28766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28767         LDKThirtyTwoBytes val_ref;
28768         CHECK(val->arr_len == 32);
28769         memcpy(val_ref.data, val->elems, 32); FREE(val);
28770         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28771 }
28772
28773 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28774         LDKRevokeAndACK this_ptr_conv;
28775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28776         this_ptr_conv.is_owned = false;
28777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28778         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28779         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28780         return ret_arr;
28781 }
28782
28783 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28784         LDKRevokeAndACK this_ptr_conv;
28785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28786         this_ptr_conv.is_owned = false;
28787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28788         LDKThirtyTwoBytes val_ref;
28789         CHECK(val->arr_len == 32);
28790         memcpy(val_ref.data, val->elems, 32); FREE(val);
28791         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28792 }
28793
28794 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28795         LDKRevokeAndACK this_ptr_conv;
28796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28797         this_ptr_conv.is_owned = false;
28798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28799         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28800         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28801         return ret_arr;
28802 }
28803
28804 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) {
28805         LDKRevokeAndACK this_ptr_conv;
28806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28807         this_ptr_conv.is_owned = false;
28808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28809         LDKPublicKey val_ref;
28810         CHECK(val->arr_len == 33);
28811         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28812         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28813 }
28814
28815 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) {
28816         LDKThirtyTwoBytes channel_id_arg_ref;
28817         CHECK(channel_id_arg->arr_len == 32);
28818         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28819         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28820         CHECK(per_commitment_secret_arg->arr_len == 32);
28821         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28822         LDKPublicKey next_per_commitment_point_arg_ref;
28823         CHECK(next_per_commitment_point_arg->arr_len == 33);
28824         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28825         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28826         uint32_t ret_ref = 0;
28827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28830         ret_ref = (uintptr_t)ret_var.inner;
28831         if (ret_var.is_owned) {
28832                 ret_ref |= 1;
28833         }
28834         return ret_ref;
28835 }
28836
28837 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28838         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28839 uint32_t ret_ref = 0;
28840 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28841 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28842 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28843 ret_ref = (uintptr_t)ret_var.inner;
28844 if (ret_var.is_owned) {
28845         ret_ref |= 1;
28846 }
28847         return ret_ref;
28848 }
28849 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28850         LDKRevokeAndACK arg_conv;
28851         arg_conv.inner = (void*)(arg & (~1));
28852         arg_conv.is_owned = false;
28853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28854         uint32_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28855         return ret_val;
28856 }
28857
28858 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28859         LDKRevokeAndACK orig_conv;
28860         orig_conv.inner = (void*)(orig & (~1));
28861         orig_conv.is_owned = false;
28862         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28863         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28864         uint32_t ret_ref = 0;
28865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28868         ret_ref = (uintptr_t)ret_var.inner;
28869         if (ret_var.is_owned) {
28870                 ret_ref |= 1;
28871         }
28872         return ret_ref;
28873 }
28874
28875 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28876         LDKUpdateFee this_obj_conv;
28877         this_obj_conv.inner = (void*)(this_obj & (~1));
28878         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28880         UpdateFee_free(this_obj_conv);
28881 }
28882
28883 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28884         LDKUpdateFee this_ptr_conv;
28885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28886         this_ptr_conv.is_owned = false;
28887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28888         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28889         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28890         return ret_arr;
28891 }
28892
28893 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28894         LDKUpdateFee 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         LDKThirtyTwoBytes val_ref;
28899         CHECK(val->arr_len == 32);
28900         memcpy(val_ref.data, val->elems, 32); FREE(val);
28901         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28902 }
28903
28904 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28905         LDKUpdateFee this_ptr_conv;
28906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28907         this_ptr_conv.is_owned = false;
28908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28909         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28910         return ret_val;
28911 }
28912
28913 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28914         LDKUpdateFee this_ptr_conv;
28915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28916         this_ptr_conv.is_owned = false;
28917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28918         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28919 }
28920
28921 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28922         LDKThirtyTwoBytes channel_id_arg_ref;
28923         CHECK(channel_id_arg->arr_len == 32);
28924         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28925         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28926         uint32_t ret_ref = 0;
28927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28930         ret_ref = (uintptr_t)ret_var.inner;
28931         if (ret_var.is_owned) {
28932                 ret_ref |= 1;
28933         }
28934         return ret_ref;
28935 }
28936
28937 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28938         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28939 uint32_t ret_ref = 0;
28940 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28941 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28942 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28943 ret_ref = (uintptr_t)ret_var.inner;
28944 if (ret_var.is_owned) {
28945         ret_ref |= 1;
28946 }
28947         return ret_ref;
28948 }
28949 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
28950         LDKUpdateFee arg_conv;
28951         arg_conv.inner = (void*)(arg & (~1));
28952         arg_conv.is_owned = false;
28953         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28954         uint32_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28955         return ret_val;
28956 }
28957
28958 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
28959         LDKUpdateFee orig_conv;
28960         orig_conv.inner = (void*)(orig & (~1));
28961         orig_conv.is_owned = false;
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28963         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28964         uint32_t ret_ref = 0;
28965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28968         ret_ref = (uintptr_t)ret_var.inner;
28969         if (ret_var.is_owned) {
28970                 ret_ref |= 1;
28971         }
28972         return ret_ref;
28973 }
28974
28975 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
28976         LDKDataLossProtect this_obj_conv;
28977         this_obj_conv.inner = (void*)(this_obj & (~1));
28978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28980         DataLossProtect_free(this_obj_conv);
28981 }
28982
28983 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) {
28984         LDKDataLossProtect this_ptr_conv;
28985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28986         this_ptr_conv.is_owned = false;
28987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28988         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28989         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
28990         return ret_arr;
28991 }
28992
28993 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) {
28994         LDKDataLossProtect this_ptr_conv;
28995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28996         this_ptr_conv.is_owned = false;
28997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28998         LDKThirtyTwoBytes val_ref;
28999         CHECK(val->arr_len == 32);
29000         memcpy(val_ref.data, val->elems, 32); FREE(val);
29001         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
29002 }
29003
29004 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) {
29005         LDKDataLossProtect this_ptr_conv;
29006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29007         this_ptr_conv.is_owned = false;
29008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29009         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29010         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29011         return ret_arr;
29012 }
29013
29014 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) {
29015         LDKDataLossProtect this_ptr_conv;
29016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29017         this_ptr_conv.is_owned = false;
29018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29019         LDKPublicKey val_ref;
29020         CHECK(val->arr_len == 33);
29021         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29022         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
29023 }
29024
29025 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) {
29026         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
29027         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
29028         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
29029         LDKPublicKey my_current_per_commitment_point_arg_ref;
29030         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
29031         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg->elems, 33); FREE(my_current_per_commitment_point_arg);
29032         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
29033         uint32_t ret_ref = 0;
29034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29037         ret_ref = (uintptr_t)ret_var.inner;
29038         if (ret_var.is_owned) {
29039                 ret_ref |= 1;
29040         }
29041         return ret_ref;
29042 }
29043
29044 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
29045         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
29046 uint32_t ret_ref = 0;
29047 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29048 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29049 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29050 ret_ref = (uintptr_t)ret_var.inner;
29051 if (ret_var.is_owned) {
29052         ret_ref |= 1;
29053 }
29054         return ret_ref;
29055 }
29056 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
29057         LDKDataLossProtect arg_conv;
29058         arg_conv.inner = (void*)(arg & (~1));
29059         arg_conv.is_owned = false;
29060         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29061         uint32_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
29062         return ret_val;
29063 }
29064
29065 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
29066         LDKDataLossProtect orig_conv;
29067         orig_conv.inner = (void*)(orig & (~1));
29068         orig_conv.is_owned = false;
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29070         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
29071         uint32_t ret_ref = 0;
29072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29075         ret_ref = (uintptr_t)ret_var.inner;
29076         if (ret_var.is_owned) {
29077                 ret_ref |= 1;
29078         }
29079         return ret_ref;
29080 }
29081
29082 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
29083         LDKChannelReestablish this_obj_conv;
29084         this_obj_conv.inner = (void*)(this_obj & (~1));
29085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29087         ChannelReestablish_free(this_obj_conv);
29088 }
29089
29090 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
29091         LDKChannelReestablish this_ptr_conv;
29092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29093         this_ptr_conv.is_owned = false;
29094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29095         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29096         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
29097         return ret_arr;
29098 }
29099
29100 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29101         LDKChannelReestablish this_ptr_conv;
29102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29103         this_ptr_conv.is_owned = false;
29104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29105         LDKThirtyTwoBytes val_ref;
29106         CHECK(val->arr_len == 32);
29107         memcpy(val_ref.data, val->elems, 32); FREE(val);
29108         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
29109 }
29110
29111 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
29112         LDKChannelReestablish this_ptr_conv;
29113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29114         this_ptr_conv.is_owned = false;
29115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29116         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
29117         return ret_val;
29118 }
29119
29120 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) {
29121         LDKChannelReestablish this_ptr_conv;
29122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29123         this_ptr_conv.is_owned = false;
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29125         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
29126 }
29127
29128 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
29129         LDKChannelReestablish this_ptr_conv;
29130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29131         this_ptr_conv.is_owned = false;
29132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29133         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
29134         return ret_val;
29135 }
29136
29137 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) {
29138         LDKChannelReestablish this_ptr_conv;
29139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29140         this_ptr_conv.is_owned = false;
29141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29142         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
29143 }
29144
29145 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
29146         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
29147 uint32_t ret_ref = 0;
29148 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29149 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29150 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29151 ret_ref = (uintptr_t)ret_var.inner;
29152 if (ret_var.is_owned) {
29153         ret_ref |= 1;
29154 }
29155         return ret_ref;
29156 }
29157 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
29158         LDKChannelReestablish arg_conv;
29159         arg_conv.inner = (void*)(arg & (~1));
29160         arg_conv.is_owned = false;
29161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29162         uint32_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
29163         return ret_val;
29164 }
29165
29166 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
29167         LDKChannelReestablish orig_conv;
29168         orig_conv.inner = (void*)(orig & (~1));
29169         orig_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29171         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
29172         uint32_t ret_ref = 0;
29173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29176         ret_ref = (uintptr_t)ret_var.inner;
29177         if (ret_var.is_owned) {
29178                 ret_ref |= 1;
29179         }
29180         return ret_ref;
29181 }
29182
29183 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
29184         LDKAnnouncementSignatures this_obj_conv;
29185         this_obj_conv.inner = (void*)(this_obj & (~1));
29186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29188         AnnouncementSignatures_free(this_obj_conv);
29189 }
29190
29191 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
29192         LDKAnnouncementSignatures this_ptr_conv;
29193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29194         this_ptr_conv.is_owned = false;
29195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29196         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29197         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
29198         return ret_arr;
29199 }
29200
29201 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29202         LDKAnnouncementSignatures this_ptr_conv;
29203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29204         this_ptr_conv.is_owned = false;
29205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29206         LDKThirtyTwoBytes val_ref;
29207         CHECK(val->arr_len == 32);
29208         memcpy(val_ref.data, val->elems, 32); FREE(val);
29209         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
29210 }
29211
29212 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
29213         LDKAnnouncementSignatures this_ptr_conv;
29214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29215         this_ptr_conv.is_owned = false;
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29217         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
29218         return ret_val;
29219 }
29220
29221 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29222         LDKAnnouncementSignatures this_ptr_conv;
29223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29224         this_ptr_conv.is_owned = false;
29225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29226         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
29227 }
29228
29229 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
29230         LDKAnnouncementSignatures this_ptr_conv;
29231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29232         this_ptr_conv.is_owned = false;
29233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29234         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29235         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
29236         return ret_arr;
29237 }
29238
29239 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
29240         LDKAnnouncementSignatures this_ptr_conv;
29241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29242         this_ptr_conv.is_owned = false;
29243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29244         LDKSignature val_ref;
29245         CHECK(val->arr_len == 64);
29246         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29247         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
29248 }
29249
29250 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
29251         LDKAnnouncementSignatures this_ptr_conv;
29252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29253         this_ptr_conv.is_owned = false;
29254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29255         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29256         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
29257         return ret_arr;
29258 }
29259
29260 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
29261         LDKAnnouncementSignatures this_ptr_conv;
29262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29263         this_ptr_conv.is_owned = false;
29264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29265         LDKSignature val_ref;
29266         CHECK(val->arr_len == 64);
29267         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29268         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
29269 }
29270
29271 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) {
29272         LDKThirtyTwoBytes channel_id_arg_ref;
29273         CHECK(channel_id_arg->arr_len == 32);
29274         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29275         LDKSignature node_signature_arg_ref;
29276         CHECK(node_signature_arg->arr_len == 64);
29277         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
29278         LDKSignature bitcoin_signature_arg_ref;
29279         CHECK(bitcoin_signature_arg->arr_len == 64);
29280         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
29281         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
29282         uint32_t ret_ref = 0;
29283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29286         ret_ref = (uintptr_t)ret_var.inner;
29287         if (ret_var.is_owned) {
29288                 ret_ref |= 1;
29289         }
29290         return ret_ref;
29291 }
29292
29293 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
29294         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
29295 uint32_t ret_ref = 0;
29296 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29297 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29298 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29299 ret_ref = (uintptr_t)ret_var.inner;
29300 if (ret_var.is_owned) {
29301         ret_ref |= 1;
29302 }
29303         return ret_ref;
29304 }
29305 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
29306         LDKAnnouncementSignatures arg_conv;
29307         arg_conv.inner = (void*)(arg & (~1));
29308         arg_conv.is_owned = false;
29309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29310         uint32_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
29311         return ret_val;
29312 }
29313
29314 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
29315         LDKAnnouncementSignatures orig_conv;
29316         orig_conv.inner = (void*)(orig & (~1));
29317         orig_conv.is_owned = false;
29318         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29319         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
29320         uint32_t ret_ref = 0;
29321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29324         ret_ref = (uintptr_t)ret_var.inner;
29325         if (ret_var.is_owned) {
29326                 ret_ref |= 1;
29327         }
29328         return ret_ref;
29329 }
29330
29331 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
29332         if ((this_ptr & 1) != 0) return;
29333         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29334         CHECK_ACCESS(this_ptr_ptr);
29335         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
29336         FREE((void*)this_ptr);
29337         NetAddress_free(this_ptr_conv);
29338 }
29339
29340 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
29341         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29342         *ret_copy = NetAddress_clone(arg);
29343 uint32_t ret_ref = (uintptr_t)ret_copy;
29344         return ret_ref;
29345 }
29346 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
29347         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
29348         uint32_t ret_val = NetAddress_clone_ptr(arg_conv);
29349         return ret_val;
29350 }
29351
29352 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
29353         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
29354         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29355         *ret_copy = NetAddress_clone(orig_conv);
29356         uint32_t ret_ref = (uintptr_t)ret_copy;
29357         return ret_ref;
29358 }
29359
29360 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
29361         LDKFourBytes addr_ref;
29362         CHECK(addr->arr_len == 4);
29363         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
29364         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29365         *ret_copy = NetAddress_ipv4(addr_ref, port);
29366         uint32_t ret_ref = (uintptr_t)ret_copy;
29367         return ret_ref;
29368 }
29369
29370 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
29371         LDKSixteenBytes addr_ref;
29372         CHECK(addr->arr_len == 16);
29373         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
29374         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29375         *ret_copy = NetAddress_ipv6(addr_ref, port);
29376         uint32_t ret_ref = (uintptr_t)ret_copy;
29377         return ret_ref;
29378 }
29379
29380 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
29381         LDKTwelveBytes a_ref;
29382         CHECK(a->arr_len == 12);
29383         memcpy(a_ref.data, a->elems, 12); FREE(a);
29384         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29385         *ret_copy = NetAddress_onion_v2(a_ref);
29386         uint32_t ret_ref = (uintptr_t)ret_copy;
29387         return ret_ref;
29388 }
29389
29390 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) {
29391         LDKThirtyTwoBytes ed25519_pubkey_ref;
29392         CHECK(ed25519_pubkey->arr_len == 32);
29393         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
29394         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29395         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
29396         uint32_t ret_ref = (uintptr_t)ret_copy;
29397         return ret_ref;
29398 }
29399
29400 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
29401         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
29402         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
29403         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29404         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29405         CVec_u8Z_free(ret_var);
29406         return ret_arr;
29407 }
29408
29409 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
29410         LDKu8slice ser_ref;
29411         ser_ref.datalen = ser->arr_len;
29412         ser_ref.data = ser->elems /* XXX ser leaks */;
29413         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
29414         *ret_conv = NetAddress_read(ser_ref);
29415         return (uint32_t)ret_conv;
29416 }
29417
29418 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
29419         LDKUnsignedNodeAnnouncement this_obj_conv;
29420         this_obj_conv.inner = (void*)(this_obj & (~1));
29421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29423         UnsignedNodeAnnouncement_free(this_obj_conv);
29424 }
29425
29426 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
29427         LDKUnsignedNodeAnnouncement this_ptr_conv;
29428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29429         this_ptr_conv.is_owned = false;
29430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29431         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29432         uint32_t ret_ref = 0;
29433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29436         ret_ref = (uintptr_t)ret_var.inner;
29437         if (ret_var.is_owned) {
29438                 ret_ref |= 1;
29439         }
29440         return ret_ref;
29441 }
29442
29443 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29444         LDKUnsignedNodeAnnouncement this_ptr_conv;
29445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29446         this_ptr_conv.is_owned = false;
29447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29448         LDKNodeFeatures val_conv;
29449         val_conv.inner = (void*)(val & (~1));
29450         val_conv.is_owned = (val & 1) || (val == 0);
29451         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29452         val_conv = NodeFeatures_clone(&val_conv);
29453         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29454 }
29455
29456 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
29457         LDKUnsignedNodeAnnouncement this_ptr_conv;
29458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29459         this_ptr_conv.is_owned = false;
29460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29461         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29462         return ret_val;
29463 }
29464
29465 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
29466         LDKUnsignedNodeAnnouncement this_ptr_conv;
29467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29468         this_ptr_conv.is_owned = false;
29469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29470         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29471 }
29472
29473 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
29474         LDKUnsignedNodeAnnouncement this_ptr_conv;
29475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29476         this_ptr_conv.is_owned = false;
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29478         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29479         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
29480         return ret_arr;
29481 }
29482
29483 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
29484         LDKUnsignedNodeAnnouncement this_ptr_conv;
29485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29486         this_ptr_conv.is_owned = false;
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29488         LDKPublicKey val_ref;
29489         CHECK(val->arr_len == 33);
29490         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29491         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29492 }
29493
29494 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
29495         LDKUnsignedNodeAnnouncement this_ptr_conv;
29496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29497         this_ptr_conv.is_owned = false;
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29499         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
29500         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
29501         return ret_arr;
29502 }
29503
29504 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
29505         LDKUnsignedNodeAnnouncement this_ptr_conv;
29506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29507         this_ptr_conv.is_owned = false;
29508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29509         LDKThreeBytes val_ref;
29510         CHECK(val->arr_len == 3);
29511         memcpy(val_ref.data, val->elems, 3); FREE(val);
29512         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29513 }
29514
29515 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
29516         LDKUnsignedNodeAnnouncement this_ptr_conv;
29517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29518         this_ptr_conv.is_owned = false;
29519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29520         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29521         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
29522         return ret_arr;
29523 }
29524
29525 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
29526         LDKUnsignedNodeAnnouncement this_ptr_conv;
29527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29528         this_ptr_conv.is_owned = false;
29529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29530         LDKThirtyTwoBytes val_ref;
29531         CHECK(val->arr_len == 32);
29532         memcpy(val_ref.data, val->elems, 32); FREE(val);
29533         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29534 }
29535
29536 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
29537         LDKUnsignedNodeAnnouncement this_ptr_conv;
29538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29539         this_ptr_conv.is_owned = false;
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29541         LDKCVec_NetAddressZ val_constr;
29542         val_constr.datalen = val->arr_len;
29543         if (val_constr.datalen > 0)
29544                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29545         else
29546                 val_constr.data = NULL;
29547         uint32_t* val_vals = val->elems /* XXX val leaks */;
29548         for (size_t m = 0; m < val_constr.datalen; m++) {
29549                 uint32_t val_conv_12 = val_vals[m];
29550                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
29551                 CHECK_ACCESS(val_conv_12_ptr);
29552                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29553                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
29554                 val_constr.data[m] = val_conv_12_conv;
29555         }
29556         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29557 }
29558
29559 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29560         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29561 uint32_t ret_ref = 0;
29562 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29563 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29565 ret_ref = (uintptr_t)ret_var.inner;
29566 if (ret_var.is_owned) {
29567         ret_ref |= 1;
29568 }
29569         return ret_ref;
29570 }
29571 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29572         LDKUnsignedNodeAnnouncement arg_conv;
29573         arg_conv.inner = (void*)(arg & (~1));
29574         arg_conv.is_owned = false;
29575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29576         uint32_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29577         return ret_val;
29578 }
29579
29580 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29581         LDKUnsignedNodeAnnouncement orig_conv;
29582         orig_conv.inner = (void*)(orig & (~1));
29583         orig_conv.is_owned = false;
29584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29585         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29586         uint32_t ret_ref = 0;
29587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29590         ret_ref = (uintptr_t)ret_var.inner;
29591         if (ret_var.is_owned) {
29592                 ret_ref |= 1;
29593         }
29594         return ret_ref;
29595 }
29596
29597 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29598         LDKNodeAnnouncement this_obj_conv;
29599         this_obj_conv.inner = (void*)(this_obj & (~1));
29600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29602         NodeAnnouncement_free(this_obj_conv);
29603 }
29604
29605 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29606         LDKNodeAnnouncement this_ptr_conv;
29607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29608         this_ptr_conv.is_owned = false;
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29610         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29611         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29612         return ret_arr;
29613 }
29614
29615 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29616         LDKNodeAnnouncement this_ptr_conv;
29617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29618         this_ptr_conv.is_owned = false;
29619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29620         LDKSignature val_ref;
29621         CHECK(val->arr_len == 64);
29622         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29623         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29624 }
29625
29626 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29627         LDKNodeAnnouncement this_ptr_conv;
29628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29629         this_ptr_conv.is_owned = false;
29630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29631         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29632         uint32_t ret_ref = 0;
29633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29636         ret_ref = (uintptr_t)ret_var.inner;
29637         if (ret_var.is_owned) {
29638                 ret_ref |= 1;
29639         }
29640         return ret_ref;
29641 }
29642
29643 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29644         LDKNodeAnnouncement this_ptr_conv;
29645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29646         this_ptr_conv.is_owned = false;
29647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29648         LDKUnsignedNodeAnnouncement val_conv;
29649         val_conv.inner = (void*)(val & (~1));
29650         val_conv.is_owned = (val & 1) || (val == 0);
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29652         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29653         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29654 }
29655
29656 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29657         LDKSignature signature_arg_ref;
29658         CHECK(signature_arg->arr_len == 64);
29659         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29660         LDKUnsignedNodeAnnouncement contents_arg_conv;
29661         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29662         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29663         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29664         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29665         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29666         uint32_t ret_ref = 0;
29667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29670         ret_ref = (uintptr_t)ret_var.inner;
29671         if (ret_var.is_owned) {
29672                 ret_ref |= 1;
29673         }
29674         return ret_ref;
29675 }
29676
29677 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29678         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29679 uint32_t ret_ref = 0;
29680 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29681 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29682 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29683 ret_ref = (uintptr_t)ret_var.inner;
29684 if (ret_var.is_owned) {
29685         ret_ref |= 1;
29686 }
29687         return ret_ref;
29688 }
29689 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29690         LDKNodeAnnouncement arg_conv;
29691         arg_conv.inner = (void*)(arg & (~1));
29692         arg_conv.is_owned = false;
29693         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29694         uint32_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
29695         return ret_val;
29696 }
29697
29698 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29699         LDKNodeAnnouncement orig_conv;
29700         orig_conv.inner = (void*)(orig & (~1));
29701         orig_conv.is_owned = false;
29702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29703         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29704         uint32_t ret_ref = 0;
29705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29708         ret_ref = (uintptr_t)ret_var.inner;
29709         if (ret_var.is_owned) {
29710                 ret_ref |= 1;
29711         }
29712         return ret_ref;
29713 }
29714
29715 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29716         LDKUnsignedChannelAnnouncement this_obj_conv;
29717         this_obj_conv.inner = (void*)(this_obj & (~1));
29718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29720         UnsignedChannelAnnouncement_free(this_obj_conv);
29721 }
29722
29723 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29724         LDKUnsignedChannelAnnouncement this_ptr_conv;
29725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29726         this_ptr_conv.is_owned = false;
29727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29728         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29729         uint32_t ret_ref = 0;
29730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29733         ret_ref = (uintptr_t)ret_var.inner;
29734         if (ret_var.is_owned) {
29735                 ret_ref |= 1;
29736         }
29737         return ret_ref;
29738 }
29739
29740 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29741         LDKUnsignedChannelAnnouncement this_ptr_conv;
29742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29743         this_ptr_conv.is_owned = false;
29744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29745         LDKChannelFeatures val_conv;
29746         val_conv.inner = (void*)(val & (~1));
29747         val_conv.is_owned = (val & 1) || (val == 0);
29748         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29749         val_conv = ChannelFeatures_clone(&val_conv);
29750         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29751 }
29752
29753 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29754         LDKUnsignedChannelAnnouncement this_ptr_conv;
29755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29756         this_ptr_conv.is_owned = false;
29757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29758         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29759         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29760         return ret_arr;
29761 }
29762
29763 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29764         LDKUnsignedChannelAnnouncement this_ptr_conv;
29765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29766         this_ptr_conv.is_owned = false;
29767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29768         LDKThirtyTwoBytes val_ref;
29769         CHECK(val->arr_len == 32);
29770         memcpy(val_ref.data, val->elems, 32); FREE(val);
29771         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29772 }
29773
29774 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29775         LDKUnsignedChannelAnnouncement this_ptr_conv;
29776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29777         this_ptr_conv.is_owned = false;
29778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29779         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29780         return ret_val;
29781 }
29782
29783 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29784         LDKUnsignedChannelAnnouncement this_ptr_conv;
29785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29786         this_ptr_conv.is_owned = false;
29787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29788         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29789 }
29790
29791 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29792         LDKUnsignedChannelAnnouncement this_ptr_conv;
29793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29794         this_ptr_conv.is_owned = false;
29795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29796         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29797         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29798         return ret_arr;
29799 }
29800
29801 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29802         LDKUnsignedChannelAnnouncement this_ptr_conv;
29803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29804         this_ptr_conv.is_owned = false;
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29806         LDKPublicKey val_ref;
29807         CHECK(val->arr_len == 33);
29808         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29809         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29810 }
29811
29812 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29813         LDKUnsignedChannelAnnouncement this_ptr_conv;
29814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29815         this_ptr_conv.is_owned = false;
29816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29817         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29818         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29819         return ret_arr;
29820 }
29821
29822 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29823         LDKUnsignedChannelAnnouncement this_ptr_conv;
29824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29825         this_ptr_conv.is_owned = false;
29826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29827         LDKPublicKey val_ref;
29828         CHECK(val->arr_len == 33);
29829         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29830         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29831 }
29832
29833 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29834         LDKUnsignedChannelAnnouncement this_ptr_conv;
29835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29836         this_ptr_conv.is_owned = false;
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29838         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29839         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29840         return ret_arr;
29841 }
29842
29843 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29844         LDKUnsignedChannelAnnouncement this_ptr_conv;
29845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29846         this_ptr_conv.is_owned = false;
29847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29848         LDKPublicKey val_ref;
29849         CHECK(val->arr_len == 33);
29850         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29851         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29852 }
29853
29854 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29855         LDKUnsignedChannelAnnouncement this_ptr_conv;
29856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29857         this_ptr_conv.is_owned = false;
29858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29859         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29860         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29861         return ret_arr;
29862 }
29863
29864 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29865         LDKUnsignedChannelAnnouncement this_ptr_conv;
29866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29867         this_ptr_conv.is_owned = false;
29868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29869         LDKPublicKey val_ref;
29870         CHECK(val->arr_len == 33);
29871         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29872         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29873 }
29874
29875 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29876         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29877 uint32_t ret_ref = 0;
29878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29881 ret_ref = (uintptr_t)ret_var.inner;
29882 if (ret_var.is_owned) {
29883         ret_ref |= 1;
29884 }
29885         return ret_ref;
29886 }
29887 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29888         LDKUnsignedChannelAnnouncement arg_conv;
29889         arg_conv.inner = (void*)(arg & (~1));
29890         arg_conv.is_owned = false;
29891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29892         uint32_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29893         return ret_val;
29894 }
29895
29896 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29897         LDKUnsignedChannelAnnouncement orig_conv;
29898         orig_conv.inner = (void*)(orig & (~1));
29899         orig_conv.is_owned = false;
29900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29901         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29902         uint32_t ret_ref = 0;
29903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29906         ret_ref = (uintptr_t)ret_var.inner;
29907         if (ret_var.is_owned) {
29908                 ret_ref |= 1;
29909         }
29910         return ret_ref;
29911 }
29912
29913 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29914         LDKChannelAnnouncement this_obj_conv;
29915         this_obj_conv.inner = (void*)(this_obj & (~1));
29916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29918         ChannelAnnouncement_free(this_obj_conv);
29919 }
29920
29921 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29922         LDKChannelAnnouncement this_ptr_conv;
29923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29924         this_ptr_conv.is_owned = false;
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29926         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29927         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29928         return ret_arr;
29929 }
29930
29931 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29932         LDKChannelAnnouncement this_ptr_conv;
29933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29934         this_ptr_conv.is_owned = false;
29935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29936         LDKSignature val_ref;
29937         CHECK(val->arr_len == 64);
29938         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29939         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29940 }
29941
29942 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
29943         LDKChannelAnnouncement this_ptr_conv;
29944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29945         this_ptr_conv.is_owned = false;
29946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29947         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29948         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
29949         return ret_arr;
29950 }
29951
29952 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
29953         LDKChannelAnnouncement this_ptr_conv;
29954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29955         this_ptr_conv.is_owned = false;
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         LDKSignature val_ref;
29958         CHECK(val->arr_len == 64);
29959         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29960         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29961 }
29962
29963 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
29964         LDKChannelAnnouncement this_ptr_conv;
29965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29966         this_ptr_conv.is_owned = false;
29967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29968         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29969         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
29970         return ret_arr;
29971 }
29972
29973 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
29974         LDKChannelAnnouncement this_ptr_conv;
29975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29976         this_ptr_conv.is_owned = false;
29977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29978         LDKSignature val_ref;
29979         CHECK(val->arr_len == 64);
29980         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29981         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29982 }
29983
29984 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
29985         LDKChannelAnnouncement this_ptr_conv;
29986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29987         this_ptr_conv.is_owned = false;
29988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29989         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29990         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
29991         return ret_arr;
29992 }
29993
29994 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
29995         LDKChannelAnnouncement this_ptr_conv;
29996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29997         this_ptr_conv.is_owned = false;
29998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29999         LDKSignature val_ref;
30000         CHECK(val->arr_len == 64);
30001         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30002         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
30003 }
30004
30005 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
30006         LDKChannelAnnouncement this_ptr_conv;
30007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30008         this_ptr_conv.is_owned = false;
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30010         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
30011         uint32_t ret_ref = 0;
30012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30015         ret_ref = (uintptr_t)ret_var.inner;
30016         if (ret_var.is_owned) {
30017                 ret_ref |= 1;
30018         }
30019         return ret_ref;
30020 }
30021
30022 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30023         LDKChannelAnnouncement this_ptr_conv;
30024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30025         this_ptr_conv.is_owned = false;
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30027         LDKUnsignedChannelAnnouncement val_conv;
30028         val_conv.inner = (void*)(val & (~1));
30029         val_conv.is_owned = (val & 1) || (val == 0);
30030         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30031         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
30032         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
30033 }
30034
30035 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) {
30036         LDKSignature node_signature_1_arg_ref;
30037         CHECK(node_signature_1_arg->arr_len == 64);
30038         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
30039         LDKSignature node_signature_2_arg_ref;
30040         CHECK(node_signature_2_arg->arr_len == 64);
30041         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
30042         LDKSignature bitcoin_signature_1_arg_ref;
30043         CHECK(bitcoin_signature_1_arg->arr_len == 64);
30044         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
30045         LDKSignature bitcoin_signature_2_arg_ref;
30046         CHECK(bitcoin_signature_2_arg->arr_len == 64);
30047         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
30048         LDKUnsignedChannelAnnouncement contents_arg_conv;
30049         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30050         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30051         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30052         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
30053         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);
30054         uint32_t ret_ref = 0;
30055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30058         ret_ref = (uintptr_t)ret_var.inner;
30059         if (ret_var.is_owned) {
30060                 ret_ref |= 1;
30061         }
30062         return ret_ref;
30063 }
30064
30065 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
30066         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
30067 uint32_t ret_ref = 0;
30068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30071 ret_ref = (uintptr_t)ret_var.inner;
30072 if (ret_var.is_owned) {
30073         ret_ref |= 1;
30074 }
30075         return ret_ref;
30076 }
30077 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
30078         LDKChannelAnnouncement arg_conv;
30079         arg_conv.inner = (void*)(arg & (~1));
30080         arg_conv.is_owned = false;
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30082         uint32_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
30083         return ret_val;
30084 }
30085
30086 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
30087         LDKChannelAnnouncement orig_conv;
30088         orig_conv.inner = (void*)(orig & (~1));
30089         orig_conv.is_owned = false;
30090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30091         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
30092         uint32_t ret_ref = 0;
30093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30096         ret_ref = (uintptr_t)ret_var.inner;
30097         if (ret_var.is_owned) {
30098                 ret_ref |= 1;
30099         }
30100         return ret_ref;
30101 }
30102
30103 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
30104         LDKUnsignedChannelUpdate this_obj_conv;
30105         this_obj_conv.inner = (void*)(this_obj & (~1));
30106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30108         UnsignedChannelUpdate_free(this_obj_conv);
30109 }
30110
30111 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
30112         LDKUnsignedChannelUpdate this_ptr_conv;
30113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30114         this_ptr_conv.is_owned = false;
30115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30116         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30117         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
30118         return ret_arr;
30119 }
30120
30121 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30122         LDKUnsignedChannelUpdate this_ptr_conv;
30123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30124         this_ptr_conv.is_owned = false;
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30126         LDKThirtyTwoBytes val_ref;
30127         CHECK(val->arr_len == 32);
30128         memcpy(val_ref.data, val->elems, 32); FREE(val);
30129         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
30130 }
30131
30132 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
30133         LDKUnsignedChannelUpdate this_ptr_conv;
30134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30135         this_ptr_conv.is_owned = false;
30136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30137         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
30138         return ret_val;
30139 }
30140
30141 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30142         LDKUnsignedChannelUpdate this_ptr_conv;
30143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30144         this_ptr_conv.is_owned = false;
30145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30146         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
30147 }
30148
30149 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
30150         LDKUnsignedChannelUpdate this_ptr_conv;
30151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30152         this_ptr_conv.is_owned = false;
30153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30154         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
30155         return ret_val;
30156 }
30157
30158 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
30159         LDKUnsignedChannelUpdate this_ptr_conv;
30160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30161         this_ptr_conv.is_owned = false;
30162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30163         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
30164 }
30165
30166 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
30167         LDKUnsignedChannelUpdate this_ptr_conv;
30168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30169         this_ptr_conv.is_owned = false;
30170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30171         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
30172         return ret_val;
30173 }
30174
30175 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
30176         LDKUnsignedChannelUpdate this_ptr_conv;
30177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30178         this_ptr_conv.is_owned = false;
30179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30180         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
30181 }
30182
30183 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
30184         LDKUnsignedChannelUpdate this_ptr_conv;
30185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30186         this_ptr_conv.is_owned = false;
30187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30188         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
30189         return ret_val;
30190 }
30191
30192 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
30193         LDKUnsignedChannelUpdate this_ptr_conv;
30194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30195         this_ptr_conv.is_owned = false;
30196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30197         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
30198 }
30199
30200 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
30201         LDKUnsignedChannelUpdate this_ptr_conv;
30202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30203         this_ptr_conv.is_owned = false;
30204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30205         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
30206         return ret_val;
30207 }
30208
30209 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
30210         LDKUnsignedChannelUpdate this_ptr_conv;
30211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30212         this_ptr_conv.is_owned = false;
30213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30214         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
30215 }
30216
30217 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
30218         LDKUnsignedChannelUpdate this_ptr_conv;
30219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30220         this_ptr_conv.is_owned = false;
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30222         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
30223         return ret_val;
30224 }
30225
30226 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
30227         LDKUnsignedChannelUpdate this_ptr_conv;
30228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30229         this_ptr_conv.is_owned = false;
30230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30231         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
30232 }
30233
30234 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
30235         LDKUnsignedChannelUpdate this_ptr_conv;
30236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30237         this_ptr_conv.is_owned = false;
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30239         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
30240         return ret_val;
30241 }
30242
30243 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
30244         LDKUnsignedChannelUpdate this_ptr_conv;
30245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30246         this_ptr_conv.is_owned = false;
30247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30248         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
30249 }
30250
30251 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
30252         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
30253 uint32_t ret_ref = 0;
30254 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30255 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30257 ret_ref = (uintptr_t)ret_var.inner;
30258 if (ret_var.is_owned) {
30259         ret_ref |= 1;
30260 }
30261         return ret_ref;
30262 }
30263 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
30264         LDKUnsignedChannelUpdate arg_conv;
30265         arg_conv.inner = (void*)(arg & (~1));
30266         arg_conv.is_owned = false;
30267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30268         uint32_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
30269         return ret_val;
30270 }
30271
30272 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
30273         LDKUnsignedChannelUpdate orig_conv;
30274         orig_conv.inner = (void*)(orig & (~1));
30275         orig_conv.is_owned = false;
30276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30277         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
30278         uint32_t ret_ref = 0;
30279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30282         ret_ref = (uintptr_t)ret_var.inner;
30283         if (ret_var.is_owned) {
30284                 ret_ref |= 1;
30285         }
30286         return ret_ref;
30287 }
30288
30289 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
30290         LDKChannelUpdate this_obj_conv;
30291         this_obj_conv.inner = (void*)(this_obj & (~1));
30292         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30294         ChannelUpdate_free(this_obj_conv);
30295 }
30296
30297 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
30298         LDKChannelUpdate this_ptr_conv;
30299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30300         this_ptr_conv.is_owned = false;
30301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30302         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30303         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
30304         return ret_arr;
30305 }
30306
30307 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
30308         LDKChannelUpdate this_ptr_conv;
30309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30310         this_ptr_conv.is_owned = false;
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30312         LDKSignature val_ref;
30313         CHECK(val->arr_len == 64);
30314         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30315         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
30316 }
30317
30318 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
30319         LDKChannelUpdate this_ptr_conv;
30320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30321         this_ptr_conv.is_owned = false;
30322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30323         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
30324         uint32_t ret_ref = 0;
30325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30328         ret_ref = (uintptr_t)ret_var.inner;
30329         if (ret_var.is_owned) {
30330                 ret_ref |= 1;
30331         }
30332         return ret_ref;
30333 }
30334
30335 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
30336         LDKChannelUpdate this_ptr_conv;
30337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30338         this_ptr_conv.is_owned = false;
30339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30340         LDKUnsignedChannelUpdate val_conv;
30341         val_conv.inner = (void*)(val & (~1));
30342         val_conv.is_owned = (val & 1) || (val == 0);
30343         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30344         val_conv = UnsignedChannelUpdate_clone(&val_conv);
30345         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
30346 }
30347
30348 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
30349         LDKSignature signature_arg_ref;
30350         CHECK(signature_arg->arr_len == 64);
30351         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30352         LDKUnsignedChannelUpdate contents_arg_conv;
30353         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30354         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30355         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30356         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
30357         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
30358         uint32_t ret_ref = 0;
30359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30362         ret_ref = (uintptr_t)ret_var.inner;
30363         if (ret_var.is_owned) {
30364                 ret_ref |= 1;
30365         }
30366         return ret_ref;
30367 }
30368
30369 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
30370         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
30371 uint32_t ret_ref = 0;
30372 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30373 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30374 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30375 ret_ref = (uintptr_t)ret_var.inner;
30376 if (ret_var.is_owned) {
30377         ret_ref |= 1;
30378 }
30379         return ret_ref;
30380 }
30381 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
30382         LDKChannelUpdate arg_conv;
30383         arg_conv.inner = (void*)(arg & (~1));
30384         arg_conv.is_owned = false;
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30386         uint32_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
30387         return ret_val;
30388 }
30389
30390 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
30391         LDKChannelUpdate orig_conv;
30392         orig_conv.inner = (void*)(orig & (~1));
30393         orig_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30395         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
30396         uint32_t ret_ref = 0;
30397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30400         ret_ref = (uintptr_t)ret_var.inner;
30401         if (ret_var.is_owned) {
30402                 ret_ref |= 1;
30403         }
30404         return ret_ref;
30405 }
30406
30407 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
30408         LDKQueryChannelRange this_obj_conv;
30409         this_obj_conv.inner = (void*)(this_obj & (~1));
30410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30412         QueryChannelRange_free(this_obj_conv);
30413 }
30414
30415 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
30416         LDKQueryChannelRange this_ptr_conv;
30417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30418         this_ptr_conv.is_owned = false;
30419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30420         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30421         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
30422         return ret_arr;
30423 }
30424
30425 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30426         LDKQueryChannelRange this_ptr_conv;
30427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30428         this_ptr_conv.is_owned = false;
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30430         LDKThirtyTwoBytes val_ref;
30431         CHECK(val->arr_len == 32);
30432         memcpy(val_ref.data, val->elems, 32); FREE(val);
30433         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30434 }
30435
30436 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
30437         LDKQueryChannelRange this_ptr_conv;
30438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30439         this_ptr_conv.is_owned = false;
30440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30441         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30442         return ret_val;
30443 }
30444
30445 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30446         LDKQueryChannelRange this_ptr_conv;
30447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30448         this_ptr_conv.is_owned = false;
30449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30450         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30451 }
30452
30453 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30454         LDKQueryChannelRange this_ptr_conv;
30455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30456         this_ptr_conv.is_owned = false;
30457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30458         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30459         return ret_val;
30460 }
30461
30462 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30463         LDKQueryChannelRange this_ptr_conv;
30464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30465         this_ptr_conv.is_owned = false;
30466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30467         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30468 }
30469
30470 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) {
30471         LDKThirtyTwoBytes chain_hash_arg_ref;
30472         CHECK(chain_hash_arg->arr_len == 32);
30473         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30474         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30475         uint32_t ret_ref = 0;
30476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30479         ret_ref = (uintptr_t)ret_var.inner;
30480         if (ret_var.is_owned) {
30481                 ret_ref |= 1;
30482         }
30483         return ret_ref;
30484 }
30485
30486 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30487         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30488 uint32_t ret_ref = 0;
30489 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30490 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30491 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30492 ret_ref = (uintptr_t)ret_var.inner;
30493 if (ret_var.is_owned) {
30494         ret_ref |= 1;
30495 }
30496         return ret_ref;
30497 }
30498 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
30499         LDKQueryChannelRange arg_conv;
30500         arg_conv.inner = (void*)(arg & (~1));
30501         arg_conv.is_owned = false;
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30503         uint32_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
30504         return ret_val;
30505 }
30506
30507 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
30508         LDKQueryChannelRange orig_conv;
30509         orig_conv.inner = (void*)(orig & (~1));
30510         orig_conv.is_owned = false;
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30512         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30513         uint32_t ret_ref = 0;
30514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30517         ret_ref = (uintptr_t)ret_var.inner;
30518         if (ret_var.is_owned) {
30519                 ret_ref |= 1;
30520         }
30521         return ret_ref;
30522 }
30523
30524 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
30525         LDKReplyChannelRange this_obj_conv;
30526         this_obj_conv.inner = (void*)(this_obj & (~1));
30527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30529         ReplyChannelRange_free(this_obj_conv);
30530 }
30531
30532 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
30533         LDKReplyChannelRange this_ptr_conv;
30534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30535         this_ptr_conv.is_owned = false;
30536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30537         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30538         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
30539         return ret_arr;
30540 }
30541
30542 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30543         LDKReplyChannelRange this_ptr_conv;
30544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30545         this_ptr_conv.is_owned = false;
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30547         LDKThirtyTwoBytes val_ref;
30548         CHECK(val->arr_len == 32);
30549         memcpy(val_ref.data, val->elems, 32); FREE(val);
30550         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30551 }
30552
30553 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
30554         LDKReplyChannelRange this_ptr_conv;
30555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30556         this_ptr_conv.is_owned = false;
30557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30558         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30559         return ret_val;
30560 }
30561
30562 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30563         LDKReplyChannelRange this_ptr_conv;
30564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30565         this_ptr_conv.is_owned = false;
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30567         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30568 }
30569
30570 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30571         LDKReplyChannelRange this_ptr_conv;
30572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30573         this_ptr_conv.is_owned = false;
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30575         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30576         return ret_val;
30577 }
30578
30579 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30580         LDKReplyChannelRange this_ptr_conv;
30581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30582         this_ptr_conv.is_owned = false;
30583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30584         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30585 }
30586
30587 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30588         LDKReplyChannelRange this_ptr_conv;
30589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30590         this_ptr_conv.is_owned = false;
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30592         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30593         return ret_val;
30594 }
30595
30596 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30597         LDKReplyChannelRange this_ptr_conv;
30598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30599         this_ptr_conv.is_owned = false;
30600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30601         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30602 }
30603
30604 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30605         LDKReplyChannelRange this_ptr_conv;
30606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30607         this_ptr_conv.is_owned = false;
30608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30609         LDKCVec_u64Z val_constr;
30610         val_constr.datalen = val->arr_len;
30611         if (val_constr.datalen > 0)
30612                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30613         else
30614                 val_constr.data = NULL;
30615         int64_t* val_vals = val->elems /* XXX val leaks */;
30616         for (size_t i = 0; i < val_constr.datalen; i++) {
30617                 int64_t val_conv_8 = val_vals[i];
30618                 val_constr.data[i] = val_conv_8;
30619         }
30620         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30621 }
30622
30623 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) {
30624         LDKThirtyTwoBytes chain_hash_arg_ref;
30625         CHECK(chain_hash_arg->arr_len == 32);
30626         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30627         LDKCVec_u64Z short_channel_ids_arg_constr;
30628         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30629         if (short_channel_ids_arg_constr.datalen > 0)
30630                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30631         else
30632                 short_channel_ids_arg_constr.data = NULL;
30633         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30634         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30635                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30636                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30637         }
30638         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30639         uint32_t ret_ref = 0;
30640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30643         ret_ref = (uintptr_t)ret_var.inner;
30644         if (ret_var.is_owned) {
30645                 ret_ref |= 1;
30646         }
30647         return ret_ref;
30648 }
30649
30650 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30651         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30652 uint32_t ret_ref = 0;
30653 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30654 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30655 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30656 ret_ref = (uintptr_t)ret_var.inner;
30657 if (ret_var.is_owned) {
30658         ret_ref |= 1;
30659 }
30660         return ret_ref;
30661 }
30662 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30663         LDKReplyChannelRange arg_conv;
30664         arg_conv.inner = (void*)(arg & (~1));
30665         arg_conv.is_owned = false;
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30667         uint32_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30668         return ret_val;
30669 }
30670
30671 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30672         LDKReplyChannelRange orig_conv;
30673         orig_conv.inner = (void*)(orig & (~1));
30674         orig_conv.is_owned = false;
30675         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30676         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30677         uint32_t ret_ref = 0;
30678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30681         ret_ref = (uintptr_t)ret_var.inner;
30682         if (ret_var.is_owned) {
30683                 ret_ref |= 1;
30684         }
30685         return ret_ref;
30686 }
30687
30688 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30689         LDKQueryShortChannelIds this_obj_conv;
30690         this_obj_conv.inner = (void*)(this_obj & (~1));
30691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30693         QueryShortChannelIds_free(this_obj_conv);
30694 }
30695
30696 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30697         LDKQueryShortChannelIds this_ptr_conv;
30698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30699         this_ptr_conv.is_owned = false;
30700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30701         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30702         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30703         return ret_arr;
30704 }
30705
30706 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30707         LDKQueryShortChannelIds this_ptr_conv;
30708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30709         this_ptr_conv.is_owned = false;
30710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30711         LDKThirtyTwoBytes val_ref;
30712         CHECK(val->arr_len == 32);
30713         memcpy(val_ref.data, val->elems, 32); FREE(val);
30714         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30715 }
30716
30717 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30718         LDKQueryShortChannelIds this_ptr_conv;
30719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30720         this_ptr_conv.is_owned = false;
30721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30722         LDKCVec_u64Z val_constr;
30723         val_constr.datalen = val->arr_len;
30724         if (val_constr.datalen > 0)
30725                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30726         else
30727                 val_constr.data = NULL;
30728         int64_t* val_vals = val->elems /* XXX val leaks */;
30729         for (size_t i = 0; i < val_constr.datalen; i++) {
30730                 int64_t val_conv_8 = val_vals[i];
30731                 val_constr.data[i] = val_conv_8;
30732         }
30733         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30734 }
30735
30736 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30737         LDKThirtyTwoBytes chain_hash_arg_ref;
30738         CHECK(chain_hash_arg->arr_len == 32);
30739         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30740         LDKCVec_u64Z short_channel_ids_arg_constr;
30741         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30742         if (short_channel_ids_arg_constr.datalen > 0)
30743                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30744         else
30745                 short_channel_ids_arg_constr.data = NULL;
30746         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30747         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30748                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30749                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30750         }
30751         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30752         uint32_t ret_ref = 0;
30753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30756         ret_ref = (uintptr_t)ret_var.inner;
30757         if (ret_var.is_owned) {
30758                 ret_ref |= 1;
30759         }
30760         return ret_ref;
30761 }
30762
30763 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30764         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30765 uint32_t ret_ref = 0;
30766 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30767 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30768 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30769 ret_ref = (uintptr_t)ret_var.inner;
30770 if (ret_var.is_owned) {
30771         ret_ref |= 1;
30772 }
30773         return ret_ref;
30774 }
30775 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30776         LDKQueryShortChannelIds arg_conv;
30777         arg_conv.inner = (void*)(arg & (~1));
30778         arg_conv.is_owned = false;
30779         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30780         uint32_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30781         return ret_val;
30782 }
30783
30784 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30785         LDKQueryShortChannelIds orig_conv;
30786         orig_conv.inner = (void*)(orig & (~1));
30787         orig_conv.is_owned = false;
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30789         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30790         uint32_t ret_ref = 0;
30791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30794         ret_ref = (uintptr_t)ret_var.inner;
30795         if (ret_var.is_owned) {
30796                 ret_ref |= 1;
30797         }
30798         return ret_ref;
30799 }
30800
30801 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30802         LDKReplyShortChannelIdsEnd this_obj_conv;
30803         this_obj_conv.inner = (void*)(this_obj & (~1));
30804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30806         ReplyShortChannelIdsEnd_free(this_obj_conv);
30807 }
30808
30809 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30810         LDKReplyShortChannelIdsEnd this_ptr_conv;
30811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30812         this_ptr_conv.is_owned = false;
30813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30814         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30815         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30816         return ret_arr;
30817 }
30818
30819 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30820         LDKReplyShortChannelIdsEnd this_ptr_conv;
30821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30822         this_ptr_conv.is_owned = false;
30823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30824         LDKThirtyTwoBytes val_ref;
30825         CHECK(val->arr_len == 32);
30826         memcpy(val_ref.data, val->elems, 32); FREE(val);
30827         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30828 }
30829
30830 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30831         LDKReplyShortChannelIdsEnd this_ptr_conv;
30832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30833         this_ptr_conv.is_owned = false;
30834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30835         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30836         return ret_val;
30837 }
30838
30839 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30840         LDKReplyShortChannelIdsEnd this_ptr_conv;
30841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30842         this_ptr_conv.is_owned = false;
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30844         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30845 }
30846
30847 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30848         LDKThirtyTwoBytes chain_hash_arg_ref;
30849         CHECK(chain_hash_arg->arr_len == 32);
30850         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30851         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30852         uint32_t ret_ref = 0;
30853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30856         ret_ref = (uintptr_t)ret_var.inner;
30857         if (ret_var.is_owned) {
30858                 ret_ref |= 1;
30859         }
30860         return ret_ref;
30861 }
30862
30863 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30864         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30865 uint32_t ret_ref = 0;
30866 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30867 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30868 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30869 ret_ref = (uintptr_t)ret_var.inner;
30870 if (ret_var.is_owned) {
30871         ret_ref |= 1;
30872 }
30873         return ret_ref;
30874 }
30875 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30876         LDKReplyShortChannelIdsEnd arg_conv;
30877         arg_conv.inner = (void*)(arg & (~1));
30878         arg_conv.is_owned = false;
30879         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30880         uint32_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30881         return ret_val;
30882 }
30883
30884 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30885         LDKReplyShortChannelIdsEnd orig_conv;
30886         orig_conv.inner = (void*)(orig & (~1));
30887         orig_conv.is_owned = false;
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30889         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30890         uint32_t ret_ref = 0;
30891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30894         ret_ref = (uintptr_t)ret_var.inner;
30895         if (ret_var.is_owned) {
30896                 ret_ref |= 1;
30897         }
30898         return ret_ref;
30899 }
30900
30901 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30902         LDKGossipTimestampFilter this_obj_conv;
30903         this_obj_conv.inner = (void*)(this_obj & (~1));
30904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30906         GossipTimestampFilter_free(this_obj_conv);
30907 }
30908
30909 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30910         LDKGossipTimestampFilter this_ptr_conv;
30911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30912         this_ptr_conv.is_owned = false;
30913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30914         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30915         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30916         return ret_arr;
30917 }
30918
30919 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30920         LDKGossipTimestampFilter this_ptr_conv;
30921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30922         this_ptr_conv.is_owned = false;
30923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30924         LDKThirtyTwoBytes val_ref;
30925         CHECK(val->arr_len == 32);
30926         memcpy(val_ref.data, val->elems, 32); FREE(val);
30927         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30928 }
30929
30930 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30931         LDKGossipTimestampFilter this_ptr_conv;
30932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30933         this_ptr_conv.is_owned = false;
30934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30935         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30936         return ret_val;
30937 }
30938
30939 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30940         LDKGossipTimestampFilter this_ptr_conv;
30941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30942         this_ptr_conv.is_owned = false;
30943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30944         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30945 }
30946
30947 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
30948         LDKGossipTimestampFilter this_ptr_conv;
30949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30950         this_ptr_conv.is_owned = false;
30951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30952         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30953         return ret_val;
30954 }
30955
30956 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
30957         LDKGossipTimestampFilter this_ptr_conv;
30958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30959         this_ptr_conv.is_owned = false;
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30961         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30962 }
30963
30964 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) {
30965         LDKThirtyTwoBytes chain_hash_arg_ref;
30966         CHECK(chain_hash_arg->arr_len == 32);
30967         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30968         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30969         uint32_t ret_ref = 0;
30970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30973         ret_ref = (uintptr_t)ret_var.inner;
30974         if (ret_var.is_owned) {
30975                 ret_ref |= 1;
30976         }
30977         return ret_ref;
30978 }
30979
30980 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30981         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30982 uint32_t ret_ref = 0;
30983 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30984 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30985 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30986 ret_ref = (uintptr_t)ret_var.inner;
30987 if (ret_var.is_owned) {
30988         ret_ref |= 1;
30989 }
30990         return ret_ref;
30991 }
30992 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
30993         LDKGossipTimestampFilter arg_conv;
30994         arg_conv.inner = (void*)(arg & (~1));
30995         arg_conv.is_owned = false;
30996         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30997         uint32_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30998         return ret_val;
30999 }
31000
31001 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
31002         LDKGossipTimestampFilter orig_conv;
31003         orig_conv.inner = (void*)(orig & (~1));
31004         orig_conv.is_owned = false;
31005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31006         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
31007         uint32_t ret_ref = 0;
31008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31011         ret_ref = (uintptr_t)ret_var.inner;
31012         if (ret_var.is_owned) {
31013                 ret_ref |= 1;
31014         }
31015         return ret_ref;
31016 }
31017
31018 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
31019         if ((this_ptr & 1) != 0) return;
31020         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31021         CHECK_ACCESS(this_ptr_ptr);
31022         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
31023         FREE((void*)this_ptr);
31024         ErrorAction_free(this_ptr_conv);
31025 }
31026
31027 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
31028         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31029         *ret_copy = ErrorAction_clone(arg);
31030 uint32_t ret_ref = (uintptr_t)ret_copy;
31031         return ret_ref;
31032 }
31033 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
31034         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
31035         uint32_t ret_val = ErrorAction_clone_ptr(arg_conv);
31036         return ret_val;
31037 }
31038
31039 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
31040         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
31041         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31042         *ret_copy = ErrorAction_clone(orig_conv);
31043         uint32_t ret_ref = (uintptr_t)ret_copy;
31044         return ret_ref;
31045 }
31046
31047 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
31048         LDKErrorMessage msg_conv;
31049         msg_conv.inner = (void*)(msg & (~1));
31050         msg_conv.is_owned = (msg & 1) || (msg == 0);
31051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31052         msg_conv = ErrorMessage_clone(&msg_conv);
31053         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31054         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
31055         uint32_t ret_ref = (uintptr_t)ret_copy;
31056         return ret_ref;
31057 }
31058
31059 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
31060         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31061         *ret_copy = ErrorAction_ignore_error();
31062         uint32_t ret_ref = (uintptr_t)ret_copy;
31063         return ret_ref;
31064 }
31065
31066 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
31067         LDKLevel a_conv = LDKLevel_from_js(a);
31068         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31069         *ret_copy = ErrorAction_ignore_and_log(a_conv);
31070         uint32_t ret_ref = (uintptr_t)ret_copy;
31071         return ret_ref;
31072 }
31073
31074 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
31075         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31076         *ret_copy = ErrorAction_ignore_duplicate_gossip();
31077         uint32_t ret_ref = (uintptr_t)ret_copy;
31078         return ret_ref;
31079 }
31080
31081 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
31082         LDKErrorMessage msg_conv;
31083         msg_conv.inner = (void*)(msg & (~1));
31084         msg_conv.is_owned = (msg & 1) || (msg == 0);
31085         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31086         msg_conv = ErrorMessage_clone(&msg_conv);
31087         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31088         *ret_copy = ErrorAction_send_error_message(msg_conv);
31089         uint32_t ret_ref = (uintptr_t)ret_copy;
31090         return ret_ref;
31091 }
31092
31093 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
31094         LDKWarningMessage msg_conv;
31095         msg_conv.inner = (void*)(msg & (~1));
31096         msg_conv.is_owned = (msg & 1) || (msg == 0);
31097         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31098         msg_conv = WarningMessage_clone(&msg_conv);
31099         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
31100         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31101         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
31102         uint32_t ret_ref = (uintptr_t)ret_copy;
31103         return ret_ref;
31104 }
31105
31106 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
31107         LDKLightningError 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         LightningError_free(this_obj_conv);
31112 }
31113
31114 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
31115         LDKLightningError this_ptr_conv;
31116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31117         this_ptr_conv.is_owned = false;
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31119         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
31120         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
31121         Str_free(ret_str);
31122         return ret_conv;
31123 }
31124
31125 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
31126         LDKLightningError this_ptr_conv;
31127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31128         this_ptr_conv.is_owned = false;
31129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31130         LDKStr val_conv = str_ref_to_owned_c(val);
31131         LightningError_set_err(&this_ptr_conv, val_conv);
31132 }
31133
31134 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
31135         LDKLightningError this_ptr_conv;
31136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31137         this_ptr_conv.is_owned = false;
31138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31139         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31140         *ret_copy = LightningError_get_action(&this_ptr_conv);
31141         uint32_t ret_ref = (uintptr_t)ret_copy;
31142         return ret_ref;
31143 }
31144
31145 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
31146         LDKLightningError this_ptr_conv;
31147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31148         this_ptr_conv.is_owned = false;
31149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31150         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31151         CHECK_ACCESS(val_ptr);
31152         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
31153         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
31154         LightningError_set_action(&this_ptr_conv, val_conv);
31155 }
31156
31157 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
31158         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
31159         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
31160         CHECK_ACCESS(action_arg_ptr);
31161         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
31162         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
31163         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
31164         uint32_t ret_ref = 0;
31165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31168         ret_ref = (uintptr_t)ret_var.inner;
31169         if (ret_var.is_owned) {
31170                 ret_ref |= 1;
31171         }
31172         return ret_ref;
31173 }
31174
31175 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
31176         LDKLightningError ret_var = LightningError_clone(arg);
31177 uint32_t ret_ref = 0;
31178 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31179 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31180 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31181 ret_ref = (uintptr_t)ret_var.inner;
31182 if (ret_var.is_owned) {
31183         ret_ref |= 1;
31184 }
31185         return ret_ref;
31186 }
31187 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
31188         LDKLightningError arg_conv;
31189         arg_conv.inner = (void*)(arg & (~1));
31190         arg_conv.is_owned = false;
31191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31192         uint32_t ret_val = LightningError_clone_ptr(&arg_conv);
31193         return ret_val;
31194 }
31195
31196 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
31197         LDKLightningError orig_conv;
31198         orig_conv.inner = (void*)(orig & (~1));
31199         orig_conv.is_owned = false;
31200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31201         LDKLightningError ret_var = LightningError_clone(&orig_conv);
31202         uint32_t ret_ref = 0;
31203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31204         CHECK((((uintptr_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 = (uintptr_t)ret_var.inner;
31207         if (ret_var.is_owned) {
31208                 ret_ref |= 1;
31209         }
31210         return ret_ref;
31211 }
31212
31213 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
31214         LDKCommitmentUpdate this_obj_conv;
31215         this_obj_conv.inner = (void*)(this_obj & (~1));
31216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31218         CommitmentUpdate_free(this_obj_conv);
31219 }
31220
31221 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
31222         LDKCommitmentUpdate this_ptr_conv;
31223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31224         this_ptr_conv.is_owned = false;
31225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31226         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
31227         uint32_tArray ret_arr = NULL;
31228         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31229         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31230         for (size_t p = 0; p < ret_var.datalen; p++) {
31231                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
31232                 uint32_t ret_conv_15_ref = 0;
31233                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31234                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31235                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
31236                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
31237                 if (ret_conv_15_var.is_owned) {
31238                         ret_conv_15_ref |= 1;
31239                 }
31240                 ret_arr_ptr[p] = ret_conv_15_ref;
31241         }
31242         
31243         FREE(ret_var.data);
31244         return ret_arr;
31245 }
31246
31247 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
31248         LDKCommitmentUpdate this_ptr_conv;
31249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31250         this_ptr_conv.is_owned = false;
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31252         LDKCVec_UpdateAddHTLCZ val_constr;
31253         val_constr.datalen = val->arr_len;
31254         if (val_constr.datalen > 0)
31255                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31256         else
31257                 val_constr.data = NULL;
31258         uint32_t* val_vals = val->elems /* XXX val leaks */;
31259         for (size_t p = 0; p < val_constr.datalen; p++) {
31260                 uint32_t val_conv_15 = val_vals[p];
31261                 LDKUpdateAddHTLC val_conv_15_conv;
31262                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
31263                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
31264                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
31265                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
31266                 val_constr.data[p] = val_conv_15_conv;
31267         }
31268         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
31269 }
31270
31271 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
31272         LDKCommitmentUpdate this_ptr_conv;
31273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31274         this_ptr_conv.is_owned = false;
31275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31276         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
31277         uint32_tArray ret_arr = NULL;
31278         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31279         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31280         for (size_t t = 0; t < ret_var.datalen; t++) {
31281                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
31282                 uint32_t ret_conv_19_ref = 0;
31283                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31284                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
31286                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
31287                 if (ret_conv_19_var.is_owned) {
31288                         ret_conv_19_ref |= 1;
31289                 }
31290                 ret_arr_ptr[t] = ret_conv_19_ref;
31291         }
31292         
31293         FREE(ret_var.data);
31294         return ret_arr;
31295 }
31296
31297 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
31298         LDKCommitmentUpdate this_ptr_conv;
31299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31300         this_ptr_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31302         LDKCVec_UpdateFulfillHTLCZ val_constr;
31303         val_constr.datalen = val->arr_len;
31304         if (val_constr.datalen > 0)
31305                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31306         else
31307                 val_constr.data = NULL;
31308         uint32_t* val_vals = val->elems /* XXX val leaks */;
31309         for (size_t t = 0; t < val_constr.datalen; t++) {
31310                 uint32_t val_conv_19 = val_vals[t];
31311                 LDKUpdateFulfillHTLC val_conv_19_conv;
31312                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
31313                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
31314                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
31315                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
31316                 val_constr.data[t] = val_conv_19_conv;
31317         }
31318         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
31319 }
31320
31321 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
31322         LDKCommitmentUpdate this_ptr_conv;
31323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31324         this_ptr_conv.is_owned = false;
31325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31326         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
31327         uint32_tArray ret_arr = NULL;
31328         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31329         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31330         for (size_t q = 0; q < ret_var.datalen; q++) {
31331                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
31332                 uint32_t ret_conv_16_ref = 0;
31333                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31334                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31335                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31336                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
31337                 if (ret_conv_16_var.is_owned) {
31338                         ret_conv_16_ref |= 1;
31339                 }
31340                 ret_arr_ptr[q] = ret_conv_16_ref;
31341         }
31342         
31343         FREE(ret_var.data);
31344         return ret_arr;
31345 }
31346
31347 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
31348         LDKCommitmentUpdate this_ptr_conv;
31349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31350         this_ptr_conv.is_owned = false;
31351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31352         LDKCVec_UpdateFailHTLCZ val_constr;
31353         val_constr.datalen = val->arr_len;
31354         if (val_constr.datalen > 0)
31355                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31356         else
31357                 val_constr.data = NULL;
31358         uint32_t* val_vals = val->elems /* XXX val leaks */;
31359         for (size_t q = 0; q < val_constr.datalen; q++) {
31360                 uint32_t val_conv_16 = val_vals[q];
31361                 LDKUpdateFailHTLC val_conv_16_conv;
31362                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
31363                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
31364                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31365                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
31366                 val_constr.data[q] = val_conv_16_conv;
31367         }
31368         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
31369 }
31370
31371 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
31372         LDKCommitmentUpdate this_ptr_conv;
31373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31374         this_ptr_conv.is_owned = false;
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31376         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
31377         uint32_tArray ret_arr = NULL;
31378         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31379         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31380         for (size_t z = 0; z < ret_var.datalen; z++) {
31381                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
31382                 uint32_t ret_conv_25_ref = 0;
31383                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31384                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
31386                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
31387                 if (ret_conv_25_var.is_owned) {
31388                         ret_conv_25_ref |= 1;
31389                 }
31390                 ret_arr_ptr[z] = ret_conv_25_ref;
31391         }
31392         
31393         FREE(ret_var.data);
31394         return ret_arr;
31395 }
31396
31397 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) {
31398         LDKCommitmentUpdate this_ptr_conv;
31399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31400         this_ptr_conv.is_owned = false;
31401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31402         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
31403         val_constr.datalen = val->arr_len;
31404         if (val_constr.datalen > 0)
31405                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31406         else
31407                 val_constr.data = NULL;
31408         uint32_t* val_vals = val->elems /* XXX val leaks */;
31409         for (size_t z = 0; z < val_constr.datalen; z++) {
31410                 uint32_t val_conv_25 = val_vals[z];
31411                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
31412                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
31413                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
31414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
31415                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
31416                 val_constr.data[z] = val_conv_25_conv;
31417         }
31418         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31419 }
31420
31421 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
31422         LDKCommitmentUpdate this_ptr_conv;
31423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31424         this_ptr_conv.is_owned = false;
31425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31426         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31427         uint32_t ret_ref = 0;
31428         if ((uintptr_t)ret_var.inner > 4096) {
31429                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31430                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31432                 ret_ref = (uintptr_t)ret_var.inner;
31433                 if (ret_var.is_owned) {
31434                         ret_ref |= 1;
31435                 }
31436         }
31437         return ret_ref;
31438 }
31439
31440 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
31441         LDKCommitmentUpdate this_ptr_conv;
31442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31443         this_ptr_conv.is_owned = false;
31444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31445         LDKUpdateFee val_conv;
31446         val_conv.inner = (void*)(val & (~1));
31447         val_conv.is_owned = (val & 1) || (val == 0);
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31449         val_conv = UpdateFee_clone(&val_conv);
31450         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31451 }
31452
31453 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
31454         LDKCommitmentUpdate this_ptr_conv;
31455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31456         this_ptr_conv.is_owned = false;
31457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31458         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31459         uint32_t ret_ref = 0;
31460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31463         ret_ref = (uintptr_t)ret_var.inner;
31464         if (ret_var.is_owned) {
31465                 ret_ref |= 1;
31466         }
31467         return ret_ref;
31468 }
31469
31470 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
31471         LDKCommitmentUpdate this_ptr_conv;
31472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31473         this_ptr_conv.is_owned = false;
31474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31475         LDKCommitmentSigned val_conv;
31476         val_conv.inner = (void*)(val & (~1));
31477         val_conv.is_owned = (val & 1) || (val == 0);
31478         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31479         val_conv = CommitmentSigned_clone(&val_conv);
31480         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31481 }
31482
31483 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) {
31484         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31485         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
31486         if (update_add_htlcs_arg_constr.datalen > 0)
31487                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31488         else
31489                 update_add_htlcs_arg_constr.data = NULL;
31490         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
31491         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31492                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31493                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31494                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31495                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31497                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31498                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31499         }
31500         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31501         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
31502         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31503                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31504         else
31505                 update_fulfill_htlcs_arg_constr.data = NULL;
31506         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
31507         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31508                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31509                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31510                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31511                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31512                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31513                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31514                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31515         }
31516         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31517         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
31518         if (update_fail_htlcs_arg_constr.datalen > 0)
31519                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31520         else
31521                 update_fail_htlcs_arg_constr.data = NULL;
31522         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
31523         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31524                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31525                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31526                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31527                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31528                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31529                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31530                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31531         }
31532         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31533         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
31534         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31535                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31536         else
31537                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31538         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
31539         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31540                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31541                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31542                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31543                 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);
31544                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31545                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31546                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31547         }
31548         LDKUpdateFee update_fee_arg_conv;
31549         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31550         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31551         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31552         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31553         LDKCommitmentSigned commitment_signed_arg_conv;
31554         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31555         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31556         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31557         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31558         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);
31559         uint32_t ret_ref = 0;
31560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31563         ret_ref = (uintptr_t)ret_var.inner;
31564         if (ret_var.is_owned) {
31565                 ret_ref |= 1;
31566         }
31567         return ret_ref;
31568 }
31569
31570 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31571         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31572 uint32_t ret_ref = 0;
31573 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31574 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31575 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31576 ret_ref = (uintptr_t)ret_var.inner;
31577 if (ret_var.is_owned) {
31578         ret_ref |= 1;
31579 }
31580         return ret_ref;
31581 }
31582 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31583         LDKCommitmentUpdate arg_conv;
31584         arg_conv.inner = (void*)(arg & (~1));
31585         arg_conv.is_owned = false;
31586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31587         uint32_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31588         return ret_val;
31589 }
31590
31591 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31592         LDKCommitmentUpdate orig_conv;
31593         orig_conv.inner = (void*)(orig & (~1));
31594         orig_conv.is_owned = false;
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31596         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31597         uint32_t ret_ref = 0;
31598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31601         ret_ref = (uintptr_t)ret_var.inner;
31602         if (ret_var.is_owned) {
31603                 ret_ref |= 1;
31604         }
31605         return ret_ref;
31606 }
31607
31608 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31609         if ((this_ptr & 1) != 0) return;
31610         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31611         CHECK_ACCESS(this_ptr_ptr);
31612         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31613         FREE((void*)this_ptr);
31614         ChannelMessageHandler_free(this_ptr_conv);
31615 }
31616
31617 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31618         if ((this_ptr & 1) != 0) return;
31619         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31620         CHECK_ACCESS(this_ptr_ptr);
31621         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31622         FREE((void*)this_ptr);
31623         RoutingMessageHandler_free(this_ptr_conv);
31624 }
31625
31626 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31627         LDKAcceptChannel obj_conv;
31628         obj_conv.inner = (void*)(obj & (~1));
31629         obj_conv.is_owned = false;
31630         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31631         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31632         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31633         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31634         CVec_u8Z_free(ret_var);
31635         return ret_arr;
31636 }
31637
31638 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31639         LDKu8slice ser_ref;
31640         ser_ref.datalen = ser->arr_len;
31641         ser_ref.data = ser->elems /* XXX ser leaks */;
31642         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31643         *ret_conv = AcceptChannel_read(ser_ref);
31644         return (uint32_t)ret_conv;
31645 }
31646
31647 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31648         LDKAnnouncementSignatures obj_conv;
31649         obj_conv.inner = (void*)(obj & (~1));
31650         obj_conv.is_owned = false;
31651         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31652         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31653         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31654         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31655         CVec_u8Z_free(ret_var);
31656         return ret_arr;
31657 }
31658
31659 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31660         LDKu8slice ser_ref;
31661         ser_ref.datalen = ser->arr_len;
31662         ser_ref.data = ser->elems /* XXX ser leaks */;
31663         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31664         *ret_conv = AnnouncementSignatures_read(ser_ref);
31665         return (uint32_t)ret_conv;
31666 }
31667
31668 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31669         LDKChannelReestablish obj_conv;
31670         obj_conv.inner = (void*)(obj & (~1));
31671         obj_conv.is_owned = false;
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31673         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31674         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31675         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31676         CVec_u8Z_free(ret_var);
31677         return ret_arr;
31678 }
31679
31680 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31681         LDKu8slice ser_ref;
31682         ser_ref.datalen = ser->arr_len;
31683         ser_ref.data = ser->elems /* XXX ser leaks */;
31684         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31685         *ret_conv = ChannelReestablish_read(ser_ref);
31686         return (uint32_t)ret_conv;
31687 }
31688
31689 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31690         LDKClosingSigned obj_conv;
31691         obj_conv.inner = (void*)(obj & (~1));
31692         obj_conv.is_owned = false;
31693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31694         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31695         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31696         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31697         CVec_u8Z_free(ret_var);
31698         return ret_arr;
31699 }
31700
31701 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31702         LDKu8slice ser_ref;
31703         ser_ref.datalen = ser->arr_len;
31704         ser_ref.data = ser->elems /* XXX ser leaks */;
31705         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31706         *ret_conv = ClosingSigned_read(ser_ref);
31707         return (uint32_t)ret_conv;
31708 }
31709
31710 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31711         LDKClosingSignedFeeRange obj_conv;
31712         obj_conv.inner = (void*)(obj & (~1));
31713         obj_conv.is_owned = false;
31714         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31715         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31716         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31717         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31718         CVec_u8Z_free(ret_var);
31719         return ret_arr;
31720 }
31721
31722 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31723         LDKu8slice ser_ref;
31724         ser_ref.datalen = ser->arr_len;
31725         ser_ref.data = ser->elems /* XXX ser leaks */;
31726         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31727         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31728         return (uint32_t)ret_conv;
31729 }
31730
31731 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31732         LDKCommitmentSigned obj_conv;
31733         obj_conv.inner = (void*)(obj & (~1));
31734         obj_conv.is_owned = false;
31735         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31736         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31737         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31738         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31739         CVec_u8Z_free(ret_var);
31740         return ret_arr;
31741 }
31742
31743 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31744         LDKu8slice ser_ref;
31745         ser_ref.datalen = ser->arr_len;
31746         ser_ref.data = ser->elems /* XXX ser leaks */;
31747         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31748         *ret_conv = CommitmentSigned_read(ser_ref);
31749         return (uint32_t)ret_conv;
31750 }
31751
31752 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31753         LDKFundingCreated obj_conv;
31754         obj_conv.inner = (void*)(obj & (~1));
31755         obj_conv.is_owned = false;
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31757         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31758         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31759         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31760         CVec_u8Z_free(ret_var);
31761         return ret_arr;
31762 }
31763
31764 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31765         LDKu8slice ser_ref;
31766         ser_ref.datalen = ser->arr_len;
31767         ser_ref.data = ser->elems /* XXX ser leaks */;
31768         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31769         *ret_conv = FundingCreated_read(ser_ref);
31770         return (uint32_t)ret_conv;
31771 }
31772
31773 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31774         LDKFundingSigned obj_conv;
31775         obj_conv.inner = (void*)(obj & (~1));
31776         obj_conv.is_owned = false;
31777         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31778         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31779         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31780         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31781         CVec_u8Z_free(ret_var);
31782         return ret_arr;
31783 }
31784
31785 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31786         LDKu8slice ser_ref;
31787         ser_ref.datalen = ser->arr_len;
31788         ser_ref.data = ser->elems /* XXX ser leaks */;
31789         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31790         *ret_conv = FundingSigned_read(ser_ref);
31791         return (uint32_t)ret_conv;
31792 }
31793
31794 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31795         LDKFundingLocked obj_conv;
31796         obj_conv.inner = (void*)(obj & (~1));
31797         obj_conv.is_owned = false;
31798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31799         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31800         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31801         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31802         CVec_u8Z_free(ret_var);
31803         return ret_arr;
31804 }
31805
31806 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31807         LDKu8slice ser_ref;
31808         ser_ref.datalen = ser->arr_len;
31809         ser_ref.data = ser->elems /* XXX ser leaks */;
31810         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31811         *ret_conv = FundingLocked_read(ser_ref);
31812         return (uint32_t)ret_conv;
31813 }
31814
31815 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31816         LDKInit obj_conv;
31817         obj_conv.inner = (void*)(obj & (~1));
31818         obj_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31820         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31821         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31822         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31823         CVec_u8Z_free(ret_var);
31824         return ret_arr;
31825 }
31826
31827 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31828         LDKu8slice ser_ref;
31829         ser_ref.datalen = ser->arr_len;
31830         ser_ref.data = ser->elems /* XXX ser leaks */;
31831         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31832         *ret_conv = Init_read(ser_ref);
31833         return (uint32_t)ret_conv;
31834 }
31835
31836 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31837         LDKOpenChannel obj_conv;
31838         obj_conv.inner = (void*)(obj & (~1));
31839         obj_conv.is_owned = false;
31840         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31841         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31842         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31843         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31844         CVec_u8Z_free(ret_var);
31845         return ret_arr;
31846 }
31847
31848 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31849         LDKu8slice ser_ref;
31850         ser_ref.datalen = ser->arr_len;
31851         ser_ref.data = ser->elems /* XXX ser leaks */;
31852         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31853         *ret_conv = OpenChannel_read(ser_ref);
31854         return (uint32_t)ret_conv;
31855 }
31856
31857 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31858         LDKRevokeAndACK obj_conv;
31859         obj_conv.inner = (void*)(obj & (~1));
31860         obj_conv.is_owned = false;
31861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31862         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31863         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31864         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31865         CVec_u8Z_free(ret_var);
31866         return ret_arr;
31867 }
31868
31869 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31870         LDKu8slice ser_ref;
31871         ser_ref.datalen = ser->arr_len;
31872         ser_ref.data = ser->elems /* XXX ser leaks */;
31873         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31874         *ret_conv = RevokeAndACK_read(ser_ref);
31875         return (uint32_t)ret_conv;
31876 }
31877
31878 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31879         LDKShutdown obj_conv;
31880         obj_conv.inner = (void*)(obj & (~1));
31881         obj_conv.is_owned = false;
31882         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31883         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31884         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31885         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31886         CVec_u8Z_free(ret_var);
31887         return ret_arr;
31888 }
31889
31890 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31891         LDKu8slice ser_ref;
31892         ser_ref.datalen = ser->arr_len;
31893         ser_ref.data = ser->elems /* XXX ser leaks */;
31894         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31895         *ret_conv = Shutdown_read(ser_ref);
31896         return (uint32_t)ret_conv;
31897 }
31898
31899 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31900         LDKUpdateFailHTLC obj_conv;
31901         obj_conv.inner = (void*)(obj & (~1));
31902         obj_conv.is_owned = false;
31903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31904         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31907         CVec_u8Z_free(ret_var);
31908         return ret_arr;
31909 }
31910
31911 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31912         LDKu8slice ser_ref;
31913         ser_ref.datalen = ser->arr_len;
31914         ser_ref.data = ser->elems /* XXX ser leaks */;
31915         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31916         *ret_conv = UpdateFailHTLC_read(ser_ref);
31917         return (uint32_t)ret_conv;
31918 }
31919
31920 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31921         LDKUpdateFailMalformedHTLC obj_conv;
31922         obj_conv.inner = (void*)(obj & (~1));
31923         obj_conv.is_owned = false;
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31925         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31926         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31927         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31928         CVec_u8Z_free(ret_var);
31929         return ret_arr;
31930 }
31931
31932 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31933         LDKu8slice ser_ref;
31934         ser_ref.datalen = ser->arr_len;
31935         ser_ref.data = ser->elems /* XXX ser leaks */;
31936         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31937         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31938         return (uint32_t)ret_conv;
31939 }
31940
31941 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
31942         LDKUpdateFee obj_conv;
31943         obj_conv.inner = (void*)(obj & (~1));
31944         obj_conv.is_owned = false;
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31946         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
31947         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31948         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31949         CVec_u8Z_free(ret_var);
31950         return ret_arr;
31951 }
31952
31953 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
31954         LDKu8slice ser_ref;
31955         ser_ref.datalen = ser->arr_len;
31956         ser_ref.data = ser->elems /* XXX ser leaks */;
31957         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31958         *ret_conv = UpdateFee_read(ser_ref);
31959         return (uint32_t)ret_conv;
31960 }
31961
31962 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
31963         LDKUpdateFulfillHTLC obj_conv;
31964         obj_conv.inner = (void*)(obj & (~1));
31965         obj_conv.is_owned = false;
31966         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31967         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
31968         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31969         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31970         CVec_u8Z_free(ret_var);
31971         return ret_arr;
31972 }
31973
31974 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
31975         LDKu8slice ser_ref;
31976         ser_ref.datalen = ser->arr_len;
31977         ser_ref.data = ser->elems /* XXX ser leaks */;
31978         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31979         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31980         return (uint32_t)ret_conv;
31981 }
31982
31983 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
31984         LDKUpdateAddHTLC obj_conv;
31985         obj_conv.inner = (void*)(obj & (~1));
31986         obj_conv.is_owned = false;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31988         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
31989         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31990         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31991         CVec_u8Z_free(ret_var);
31992         return ret_arr;
31993 }
31994
31995 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
31996         LDKu8slice ser_ref;
31997         ser_ref.datalen = ser->arr_len;
31998         ser_ref.data = ser->elems /* XXX ser leaks */;
31999         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
32000         *ret_conv = UpdateAddHTLC_read(ser_ref);
32001         return (uint32_t)ret_conv;
32002 }
32003
32004 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
32005         LDKPing obj_conv;
32006         obj_conv.inner = (void*)(obj & (~1));
32007         obj_conv.is_owned = false;
32008         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32009         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
32010         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32011         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32012         CVec_u8Z_free(ret_var);
32013         return ret_arr;
32014 }
32015
32016 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
32017         LDKu8slice ser_ref;
32018         ser_ref.datalen = ser->arr_len;
32019         ser_ref.data = ser->elems /* XXX ser leaks */;
32020         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
32021         *ret_conv = Ping_read(ser_ref);
32022         return (uint32_t)ret_conv;
32023 }
32024
32025 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
32026         LDKPong obj_conv;
32027         obj_conv.inner = (void*)(obj & (~1));
32028         obj_conv.is_owned = false;
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32030         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
32031         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32032         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32033         CVec_u8Z_free(ret_var);
32034         return ret_arr;
32035 }
32036
32037 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
32038         LDKu8slice ser_ref;
32039         ser_ref.datalen = ser->arr_len;
32040         ser_ref.data = ser->elems /* XXX ser leaks */;
32041         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
32042         *ret_conv = Pong_read(ser_ref);
32043         return (uint32_t)ret_conv;
32044 }
32045
32046 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
32047         LDKUnsignedChannelAnnouncement obj_conv;
32048         obj_conv.inner = (void*)(obj & (~1));
32049         obj_conv.is_owned = false;
32050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32051         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
32052         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32053         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32054         CVec_u8Z_free(ret_var);
32055         return ret_arr;
32056 }
32057
32058 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
32059         LDKu8slice ser_ref;
32060         ser_ref.datalen = ser->arr_len;
32061         ser_ref.data = ser->elems /* XXX ser leaks */;
32062         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
32063         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
32064         return (uint32_t)ret_conv;
32065 }
32066
32067 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
32068         LDKChannelAnnouncement obj_conv;
32069         obj_conv.inner = (void*)(obj & (~1));
32070         obj_conv.is_owned = false;
32071         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32072         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
32073         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32074         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32075         CVec_u8Z_free(ret_var);
32076         return ret_arr;
32077 }
32078
32079 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
32080         LDKu8slice ser_ref;
32081         ser_ref.datalen = ser->arr_len;
32082         ser_ref.data = ser->elems /* XXX ser leaks */;
32083         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
32084         *ret_conv = ChannelAnnouncement_read(ser_ref);
32085         return (uint32_t)ret_conv;
32086 }
32087
32088 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
32089         LDKUnsignedChannelUpdate obj_conv;
32090         obj_conv.inner = (void*)(obj & (~1));
32091         obj_conv.is_owned = false;
32092         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32093         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
32094         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32095         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32096         CVec_u8Z_free(ret_var);
32097         return ret_arr;
32098 }
32099
32100 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
32101         LDKu8slice ser_ref;
32102         ser_ref.datalen = ser->arr_len;
32103         ser_ref.data = ser->elems /* XXX ser leaks */;
32104         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
32105         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
32106         return (uint32_t)ret_conv;
32107 }
32108
32109 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
32110         LDKChannelUpdate obj_conv;
32111         obj_conv.inner = (void*)(obj & (~1));
32112         obj_conv.is_owned = false;
32113         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32114         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
32115         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32116         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32117         CVec_u8Z_free(ret_var);
32118         return ret_arr;
32119 }
32120
32121 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
32122         LDKu8slice ser_ref;
32123         ser_ref.datalen = ser->arr_len;
32124         ser_ref.data = ser->elems /* XXX ser leaks */;
32125         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
32126         *ret_conv = ChannelUpdate_read(ser_ref);
32127         return (uint32_t)ret_conv;
32128 }
32129
32130 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
32131         LDKErrorMessage obj_conv;
32132         obj_conv.inner = (void*)(obj & (~1));
32133         obj_conv.is_owned = false;
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32135         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
32136         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32137         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32138         CVec_u8Z_free(ret_var);
32139         return ret_arr;
32140 }
32141
32142 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
32143         LDKu8slice ser_ref;
32144         ser_ref.datalen = ser->arr_len;
32145         ser_ref.data = ser->elems /* XXX ser leaks */;
32146         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
32147         *ret_conv = ErrorMessage_read(ser_ref);
32148         return (uint32_t)ret_conv;
32149 }
32150
32151 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
32152         LDKWarningMessage obj_conv;
32153         obj_conv.inner = (void*)(obj & (~1));
32154         obj_conv.is_owned = false;
32155         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32156         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
32157         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32158         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32159         CVec_u8Z_free(ret_var);
32160         return ret_arr;
32161 }
32162
32163 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
32164         LDKu8slice ser_ref;
32165         ser_ref.datalen = ser->arr_len;
32166         ser_ref.data = ser->elems /* XXX ser leaks */;
32167         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
32168         *ret_conv = WarningMessage_read(ser_ref);
32169         return (uint32_t)ret_conv;
32170 }
32171
32172 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
32173         LDKUnsignedNodeAnnouncement obj_conv;
32174         obj_conv.inner = (void*)(obj & (~1));
32175         obj_conv.is_owned = false;
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32177         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
32178         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32179         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32180         CVec_u8Z_free(ret_var);
32181         return ret_arr;
32182 }
32183
32184 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
32185         LDKu8slice ser_ref;
32186         ser_ref.datalen = ser->arr_len;
32187         ser_ref.data = ser->elems /* XXX ser leaks */;
32188         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
32189         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
32190         return (uint32_t)ret_conv;
32191 }
32192
32193 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
32194         LDKNodeAnnouncement obj_conv;
32195         obj_conv.inner = (void*)(obj & (~1));
32196         obj_conv.is_owned = false;
32197         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32198         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
32199         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32200         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32201         CVec_u8Z_free(ret_var);
32202         return ret_arr;
32203 }
32204
32205 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
32206         LDKu8slice ser_ref;
32207         ser_ref.datalen = ser->arr_len;
32208         ser_ref.data = ser->elems /* XXX ser leaks */;
32209         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
32210         *ret_conv = NodeAnnouncement_read(ser_ref);
32211         return (uint32_t)ret_conv;
32212 }
32213
32214 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
32215         LDKu8slice ser_ref;
32216         ser_ref.datalen = ser->arr_len;
32217         ser_ref.data = ser->elems /* XXX ser leaks */;
32218         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
32219         *ret_conv = QueryShortChannelIds_read(ser_ref);
32220         return (uint32_t)ret_conv;
32221 }
32222
32223 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
32224         LDKQueryShortChannelIds obj_conv;
32225         obj_conv.inner = (void*)(obj & (~1));
32226         obj_conv.is_owned = false;
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32228         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
32229         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32230         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32231         CVec_u8Z_free(ret_var);
32232         return ret_arr;
32233 }
32234
32235 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
32236         LDKReplyShortChannelIdsEnd obj_conv;
32237         obj_conv.inner = (void*)(obj & (~1));
32238         obj_conv.is_owned = false;
32239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32240         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
32241         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32242         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32243         CVec_u8Z_free(ret_var);
32244         return ret_arr;
32245 }
32246
32247 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
32248         LDKu8slice ser_ref;
32249         ser_ref.datalen = ser->arr_len;
32250         ser_ref.data = ser->elems /* XXX ser leaks */;
32251         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
32252         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
32253         return (uint32_t)ret_conv;
32254 }
32255
32256 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
32257         LDKQueryChannelRange this_arg_conv;
32258         this_arg_conv.inner = (void*)(this_arg & (~1));
32259         this_arg_conv.is_owned = false;
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32261         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
32262         return ret_val;
32263 }
32264
32265 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
32266         LDKQueryChannelRange obj_conv;
32267         obj_conv.inner = (void*)(obj & (~1));
32268         obj_conv.is_owned = false;
32269         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32270         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
32271         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32272         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32273         CVec_u8Z_free(ret_var);
32274         return ret_arr;
32275 }
32276
32277 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
32278         LDKu8slice ser_ref;
32279         ser_ref.datalen = ser->arr_len;
32280         ser_ref.data = ser->elems /* XXX ser leaks */;
32281         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
32282         *ret_conv = QueryChannelRange_read(ser_ref);
32283         return (uint32_t)ret_conv;
32284 }
32285
32286 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
32287         LDKu8slice ser_ref;
32288         ser_ref.datalen = ser->arr_len;
32289         ser_ref.data = ser->elems /* XXX ser leaks */;
32290         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
32291         *ret_conv = ReplyChannelRange_read(ser_ref);
32292         return (uint32_t)ret_conv;
32293 }
32294
32295 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
32296         LDKReplyChannelRange obj_conv;
32297         obj_conv.inner = (void*)(obj & (~1));
32298         obj_conv.is_owned = false;
32299         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32300         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
32301         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32302         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32303         CVec_u8Z_free(ret_var);
32304         return ret_arr;
32305 }
32306
32307 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
32308         LDKGossipTimestampFilter obj_conv;
32309         obj_conv.inner = (void*)(obj & (~1));
32310         obj_conv.is_owned = false;
32311         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32312         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
32313         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32314         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32315         CVec_u8Z_free(ret_var);
32316         return ret_arr;
32317 }
32318
32319 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
32320         LDKu8slice ser_ref;
32321         ser_ref.datalen = ser->arr_len;
32322         ser_ref.data = ser->elems /* XXX ser leaks */;
32323         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
32324         *ret_conv = GossipTimestampFilter_read(ser_ref);
32325         return (uint32_t)ret_conv;
32326 }
32327
32328 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
32329         if ((this_ptr & 1) != 0) return;
32330         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32331         CHECK_ACCESS(this_ptr_ptr);
32332         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
32333         FREE((void*)this_ptr);
32334         CustomMessageHandler_free(this_ptr_conv);
32335 }
32336
32337 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
32338         LDKIgnoringMessageHandler this_obj_conv;
32339         this_obj_conv.inner = (void*)(this_obj & (~1));
32340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32342         IgnoringMessageHandler_free(this_obj_conv);
32343 }
32344
32345 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
32346         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
32347         uint32_t ret_ref = 0;
32348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32351         ret_ref = (uintptr_t)ret_var.inner;
32352         if (ret_var.is_owned) {
32353                 ret_ref |= 1;
32354         }
32355         return ret_ref;
32356 }
32357
32358 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32359         LDKIgnoringMessageHandler this_arg_conv;
32360         this_arg_conv.inner = (void*)(this_arg & (~1));
32361         this_arg_conv.is_owned = false;
32362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32363         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32364         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32365         return (uint32_t)ret_ret;
32366 }
32367
32368 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
32369         LDKIgnoringMessageHandler this_arg_conv;
32370         this_arg_conv.inner = (void*)(this_arg & (~1));
32371         this_arg_conv.is_owned = false;
32372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32373         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32374         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
32375         return (uint32_t)ret_ret;
32376 }
32377
32378 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
32379         LDKIgnoringMessageHandler this_arg_conv;
32380         this_arg_conv.inner = (void*)(this_arg & (~1));
32381         this_arg_conv.is_owned = false;
32382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32383         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
32384         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
32385         return (uint32_t)ret_ret;
32386 }
32387
32388 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
32389         LDKIgnoringMessageHandler this_arg_conv;
32390         this_arg_conv.inner = (void*)(this_arg & (~1));
32391         this_arg_conv.is_owned = false;
32392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32393         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
32394         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
32395         return (uint32_t)ret_ret;
32396 }
32397
32398 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
32399         LDKErroringMessageHandler this_obj_conv;
32400         this_obj_conv.inner = (void*)(this_obj & (~1));
32401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32403         ErroringMessageHandler_free(this_obj_conv);
32404 }
32405
32406 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
32407         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
32408         uint32_t ret_ref = 0;
32409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32412         ret_ref = (uintptr_t)ret_var.inner;
32413         if (ret_var.is_owned) {
32414                 ret_ref |= 1;
32415         }
32416         return ret_ref;
32417 }
32418
32419 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32420         LDKErroringMessageHandler this_arg_conv;
32421         this_arg_conv.inner = (void*)(this_arg & (~1));
32422         this_arg_conv.is_owned = false;
32423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32424         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32425         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32426         return (uint32_t)ret_ret;
32427 }
32428
32429 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
32430         LDKErroringMessageHandler this_arg_conv;
32431         this_arg_conv.inner = (void*)(this_arg & (~1));
32432         this_arg_conv.is_owned = false;
32433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32434         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32435         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32436         return (uint32_t)ret_ret;
32437 }
32438
32439 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
32440         LDKMessageHandler this_obj_conv;
32441         this_obj_conv.inner = (void*)(this_obj & (~1));
32442         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32444         MessageHandler_free(this_obj_conv);
32445 }
32446
32447 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
32448         LDKMessageHandler this_ptr_conv;
32449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32450         this_ptr_conv.is_owned = false;
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32452         // WARNING: This object doesn't live past this scope, needs clone!
32453         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32454         return ret_ret;
32455 }
32456
32457 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
32458         LDKMessageHandler this_ptr_conv;
32459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32460         this_ptr_conv.is_owned = false;
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32462         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32463         CHECK_ACCESS(val_ptr);
32464         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32465         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
32466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32467                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
32468         }
32469         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32470 }
32471
32472 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
32473         LDKMessageHandler this_ptr_conv;
32474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32475         this_ptr_conv.is_owned = false;
32476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32477         // WARNING: This object doesn't live past this scope, needs clone!
32478         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32479         return ret_ret;
32480 }
32481
32482 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
32483         LDKMessageHandler this_ptr_conv;
32484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32485         this_ptr_conv.is_owned = false;
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32487         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32488         CHECK_ACCESS(val_ptr);
32489         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32490         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32491                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32492                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
32493         }
32494         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32495 }
32496
32497 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
32498         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
32499         CHECK_ACCESS(chan_handler_arg_ptr);
32500         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32501         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
32502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32503                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
32504         }
32505         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
32506         CHECK_ACCESS(route_handler_arg_ptr);
32507         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32508         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32509                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32510                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
32511         }
32512         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32513         uint32_t ret_ref = 0;
32514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32517         ret_ref = (uintptr_t)ret_var.inner;
32518         if (ret_var.is_owned) {
32519                 ret_ref |= 1;
32520         }
32521         return ret_ref;
32522 }
32523
32524 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32525         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32526         *ret_ret = SocketDescriptor_clone(arg);
32527         return (uint32_t)ret_ret;
32528 }
32529 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
32530         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
32531         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32532         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32533         uint32_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
32534         return ret_val;
32535 }
32536
32537 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
32538         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
32539         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32540         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32541         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32542         *ret_ret = SocketDescriptor_clone(orig_conv);
32543         return (uint32_t)ret_ret;
32544 }
32545
32546 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
32547         if ((this_ptr & 1) != 0) return;
32548         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32549         CHECK_ACCESS(this_ptr_ptr);
32550         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32551         FREE((void*)this_ptr);
32552         SocketDescriptor_free(this_ptr_conv);
32553 }
32554
32555 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
32556         LDKPeerHandleError this_obj_conv;
32557         this_obj_conv.inner = (void*)(this_obj & (~1));
32558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32560         PeerHandleError_free(this_obj_conv);
32561 }
32562
32563 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
32564         LDKPeerHandleError this_ptr_conv;
32565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32566         this_ptr_conv.is_owned = false;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32569         return ret_val;
32570 }
32571
32572 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
32573         LDKPeerHandleError this_ptr_conv;
32574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32575         this_ptr_conv.is_owned = false;
32576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32577         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32578 }
32579
32580 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32581         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32582         uint32_t ret_ref = 0;
32583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32586         ret_ref = (uintptr_t)ret_var.inner;
32587         if (ret_var.is_owned) {
32588                 ret_ref |= 1;
32589         }
32590         return ret_ref;
32591 }
32592
32593 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32594         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32595 uint32_t ret_ref = 0;
32596 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32597 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32599 ret_ref = (uintptr_t)ret_var.inner;
32600 if (ret_var.is_owned) {
32601         ret_ref |= 1;
32602 }
32603         return ret_ref;
32604 }
32605 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32606         LDKPeerHandleError arg_conv;
32607         arg_conv.inner = (void*)(arg & (~1));
32608         arg_conv.is_owned = false;
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32610         uint32_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32611         return ret_val;
32612 }
32613
32614 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32615         LDKPeerHandleError orig_conv;
32616         orig_conv.inner = (void*)(orig & (~1));
32617         orig_conv.is_owned = false;
32618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32619         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32620         uint32_t ret_ref = 0;
32621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32624         ret_ref = (uintptr_t)ret_var.inner;
32625         if (ret_var.is_owned) {
32626                 ret_ref |= 1;
32627         }
32628         return ret_ref;
32629 }
32630
32631 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32632         LDKPeerManager this_obj_conv;
32633         this_obj_conv.inner = (void*)(this_obj & (~1));
32634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32636         PeerManager_free(this_obj_conv);
32637 }
32638
32639 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) {
32640         LDKMessageHandler message_handler_conv;
32641         message_handler_conv.inner = (void*)(message_handler & (~1));
32642         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32643         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32644         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32645         LDKSecretKey our_node_secret_ref;
32646         CHECK(our_node_secret->arr_len == 32);
32647         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32648         unsigned char ephemeral_random_data_arr[32];
32649         CHECK(ephemeral_random_data->arr_len == 32);
32650         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32651         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32652         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32653         CHECK_ACCESS(logger_ptr);
32654         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32655         if (logger_conv.free == LDKLogger_JCalls_free) {
32656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32657                 LDKLogger_JCalls_cloned(&logger_conv);
32658         }
32659         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32660         CHECK_ACCESS(custom_message_handler_ptr);
32661         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32662         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
32663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32664                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
32665         }
32666         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32667         uint32_t ret_ref = 0;
32668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32671         ret_ref = (uintptr_t)ret_var.inner;
32672         if (ret_var.is_owned) {
32673                 ret_ref |= 1;
32674         }
32675         return ret_ref;
32676 }
32677
32678 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32679         LDKPeerManager this_arg_conv;
32680         this_arg_conv.inner = (void*)(this_arg & (~1));
32681         this_arg_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32683         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32684         ptrArray ret_arr = NULL;
32685         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32686         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32687         for (size_t m = 0; m < ret_var.datalen; m++) {
32688                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32689                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32690                 ret_arr_ptr[m] = ret_conv_12_arr;
32691         }
32692         
32693         FREE(ret_var.data);
32694         return ret_arr;
32695 }
32696
32697 uint32_t  __attribute__((export_name("TS_PeerManager_new_outbound_connection"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor, uint32_t remote_network_address) {
32698         LDKPeerManager this_arg_conv;
32699         this_arg_conv.inner = (void*)(this_arg & (~1));
32700         this_arg_conv.is_owned = false;
32701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32702         LDKPublicKey their_node_id_ref;
32703         CHECK(their_node_id->arr_len == 33);
32704         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32705         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32706         CHECK_ACCESS(descriptor_ptr);
32707         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32708         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32710                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32711         }
32712         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32713         CHECK_ACCESS(remote_network_address_ptr);
32714         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32715         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32716         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
32717         return (uint32_t)ret_conv;
32718 }
32719
32720 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor, uint32_t remote_network_address) {
32721         LDKPeerManager this_arg_conv;
32722         this_arg_conv.inner = (void*)(this_arg & (~1));
32723         this_arg_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32725         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32726         CHECK_ACCESS(descriptor_ptr);
32727         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32728         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32730                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32731         }
32732         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32733         CHECK_ACCESS(remote_network_address_ptr);
32734         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32735         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32736         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
32737         return (uint32_t)ret_conv;
32738 }
32739
32740 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32741         LDKPeerManager this_arg_conv;
32742         this_arg_conv.inner = (void*)(this_arg & (~1));
32743         this_arg_conv.is_owned = false;
32744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32745         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32746         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32747         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32748         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32749         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32750         return (uint32_t)ret_conv;
32751 }
32752
32753 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32754         LDKPeerManager this_arg_conv;
32755         this_arg_conv.inner = (void*)(this_arg & (~1));
32756         this_arg_conv.is_owned = false;
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32758         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32759         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32760         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32761         LDKu8slice data_ref;
32762         data_ref.datalen = data->arr_len;
32763         data_ref.data = data->elems /* XXX data leaks */;
32764         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32765         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32766         return (uint32_t)ret_conv;
32767 }
32768
32769 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32770         LDKPeerManager this_arg_conv;
32771         this_arg_conv.inner = (void*)(this_arg & (~1));
32772         this_arg_conv.is_owned = false;
32773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32774         PeerManager_process_events(&this_arg_conv);
32775 }
32776
32777 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32778         LDKPeerManager this_arg_conv;
32779         this_arg_conv.inner = (void*)(this_arg & (~1));
32780         this_arg_conv.is_owned = false;
32781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32782         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32783         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32784         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32785         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32786 }
32787
32788 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) {
32789         LDKPeerManager this_arg_conv;
32790         this_arg_conv.inner = (void*)(this_arg & (~1));
32791         this_arg_conv.is_owned = false;
32792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32793         LDKPublicKey node_id_ref;
32794         CHECK(node_id->arr_len == 33);
32795         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32796         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32797 }
32798
32799 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32800         LDKPeerManager this_arg_conv;
32801         this_arg_conv.inner = (void*)(this_arg & (~1));
32802         this_arg_conv.is_owned = false;
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32804         PeerManager_disconnect_all_peers(&this_arg_conv);
32805 }
32806
32807 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32808         LDKPeerManager this_arg_conv;
32809         this_arg_conv.inner = (void*)(this_arg & (~1));
32810         this_arg_conv.is_owned = false;
32811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32812         PeerManager_timer_tick_occurred(&this_arg_conv);
32813 }
32814
32815 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32816         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32817         return ret_val;
32818 }
32819
32820 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32821         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32822         return ret_val;
32823 }
32824
32825 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32826         unsigned char commitment_seed_arr[32];
32827         CHECK(commitment_seed->arr_len == 32);
32828         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32829         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32830         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32831         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32832         return ret_arr;
32833 }
32834
32835 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) {
32836         LDKCVec_u8Z to_holder_script_ref;
32837         to_holder_script_ref.datalen = to_holder_script->arr_len;
32838         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32839         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32840         LDKCVec_u8Z to_counterparty_script_ref;
32841         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32842         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32843         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32844         LDKOutPoint funding_outpoint_conv;
32845         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32846         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32847         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32848         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32849         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);
32850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32852         Transaction_free(ret_var);
32853         return ret_arr;
32854 }
32855
32856 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32857         LDKCounterpartyCommitmentSecrets this_obj_conv;
32858         this_obj_conv.inner = (void*)(this_obj & (~1));
32859         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32861         CounterpartyCommitmentSecrets_free(this_obj_conv);
32862 }
32863
32864 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32865         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32866 uint32_t ret_ref = 0;
32867 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32868 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32869 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32870 ret_ref = (uintptr_t)ret_var.inner;
32871 if (ret_var.is_owned) {
32872         ret_ref |= 1;
32873 }
32874         return ret_ref;
32875 }
32876 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32877         LDKCounterpartyCommitmentSecrets arg_conv;
32878         arg_conv.inner = (void*)(arg & (~1));
32879         arg_conv.is_owned = false;
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32881         uint32_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32882         return ret_val;
32883 }
32884
32885 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32886         LDKCounterpartyCommitmentSecrets orig_conv;
32887         orig_conv.inner = (void*)(orig & (~1));
32888         orig_conv.is_owned = false;
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32890         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32891         uint32_t ret_ref = 0;
32892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32895         ret_ref = (uintptr_t)ret_var.inner;
32896         if (ret_var.is_owned) {
32897                 ret_ref |= 1;
32898         }
32899         return ret_ref;
32900 }
32901
32902 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32903         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32904         uint32_t ret_ref = 0;
32905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32908         ret_ref = (uintptr_t)ret_var.inner;
32909         if (ret_var.is_owned) {
32910                 ret_ref |= 1;
32911         }
32912         return ret_ref;
32913 }
32914
32915 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32916         LDKCounterpartyCommitmentSecrets this_arg_conv;
32917         this_arg_conv.inner = (void*)(this_arg & (~1));
32918         this_arg_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32920         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32921         return ret_val;
32922 }
32923
32924 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32925         LDKCounterpartyCommitmentSecrets this_arg_conv;
32926         this_arg_conv.inner = (void*)(this_arg & (~1));
32927         this_arg_conv.is_owned = false;
32928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32929         LDKThirtyTwoBytes secret_ref;
32930         CHECK(secret->arr_len == 32);
32931         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32932         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32933         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32934         return (uint32_t)ret_conv;
32935 }
32936
32937 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32938         LDKCounterpartyCommitmentSecrets this_arg_conv;
32939         this_arg_conv.inner = (void*)(this_arg & (~1));
32940         this_arg_conv.is_owned = false;
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32942         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32943         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
32944         return ret_arr;
32945 }
32946
32947 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
32948         LDKCounterpartyCommitmentSecrets obj_conv;
32949         obj_conv.inner = (void*)(obj & (~1));
32950         obj_conv.is_owned = false;
32951         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32952         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
32953         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32954         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32955         CVec_u8Z_free(ret_var);
32956         return ret_arr;
32957 }
32958
32959 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
32960         LDKu8slice ser_ref;
32961         ser_ref.datalen = ser->arr_len;
32962         ser_ref.data = ser->elems /* XXX ser leaks */;
32963         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
32964         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
32965         return (uint32_t)ret_conv;
32966 }
32967
32968 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
32969         LDKPublicKey per_commitment_point_ref;
32970         CHECK(per_commitment_point->arr_len == 33);
32971         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32972         unsigned char base_secret_arr[32];
32973         CHECK(base_secret->arr_len == 32);
32974         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
32975         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32976         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32977         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32978         return (uint32_t)ret_conv;
32979 }
32980
32981 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
32982         LDKPublicKey per_commitment_point_ref;
32983         CHECK(per_commitment_point->arr_len == 33);
32984         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32985         LDKPublicKey base_point_ref;
32986         CHECK(base_point->arr_len == 33);
32987         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
32988         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32989         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32990         return (uint32_t)ret_conv;
32991 }
32992
32993 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) {
32994         unsigned char per_commitment_secret_arr[32];
32995         CHECK(per_commitment_secret->arr_len == 32);
32996         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
32997         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32998         unsigned char countersignatory_revocation_base_secret_arr[32];
32999         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
33000         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
33001         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
33002         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33003         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
33004         return (uint32_t)ret_conv;
33005 }
33006
33007 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) {
33008         LDKPublicKey per_commitment_point_ref;
33009         CHECK(per_commitment_point->arr_len == 33);
33010         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33011         LDKPublicKey countersignatory_revocation_base_point_ref;
33012         CHECK(countersignatory_revocation_base_point->arr_len == 33);
33013         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
33014         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33015         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
33016         return (uint32_t)ret_conv;
33017 }
33018
33019 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
33020         LDKTxCreationKeys this_obj_conv;
33021         this_obj_conv.inner = (void*)(this_obj & (~1));
33022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33024         TxCreationKeys_free(this_obj_conv);
33025 }
33026
33027 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
33028         LDKTxCreationKeys this_ptr_conv;
33029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33030         this_ptr_conv.is_owned = false;
33031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33032         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33033         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
33034         return ret_arr;
33035 }
33036
33037 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
33038         LDKTxCreationKeys this_ptr_conv;
33039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33040         this_ptr_conv.is_owned = false;
33041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33042         LDKPublicKey val_ref;
33043         CHECK(val->arr_len == 33);
33044         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33045         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
33046 }
33047
33048 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
33049         LDKTxCreationKeys this_ptr_conv;
33050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33051         this_ptr_conv.is_owned = false;
33052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33053         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33054         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
33055         return ret_arr;
33056 }
33057
33058 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
33059         LDKTxCreationKeys this_ptr_conv;
33060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33061         this_ptr_conv.is_owned = false;
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33063         LDKPublicKey val_ref;
33064         CHECK(val->arr_len == 33);
33065         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33066         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
33067 }
33068
33069 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
33070         LDKTxCreationKeys this_ptr_conv;
33071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33072         this_ptr_conv.is_owned = false;
33073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33074         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33075         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
33076         return ret_arr;
33077 }
33078
33079 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
33080         LDKTxCreationKeys this_ptr_conv;
33081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33082         this_ptr_conv.is_owned = false;
33083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33084         LDKPublicKey val_ref;
33085         CHECK(val->arr_len == 33);
33086         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33087         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
33088 }
33089
33090 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
33091         LDKTxCreationKeys this_ptr_conv;
33092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33093         this_ptr_conv.is_owned = false;
33094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33095         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33096         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
33097         return ret_arr;
33098 }
33099
33100 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
33101         LDKTxCreationKeys this_ptr_conv;
33102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33103         this_ptr_conv.is_owned = false;
33104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33105         LDKPublicKey val_ref;
33106         CHECK(val->arr_len == 33);
33107         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33108         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
33109 }
33110
33111 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
33112         LDKTxCreationKeys this_ptr_conv;
33113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33114         this_ptr_conv.is_owned = false;
33115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33116         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33117         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
33118         return ret_arr;
33119 }
33120
33121 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) {
33122         LDKTxCreationKeys this_ptr_conv;
33123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33124         this_ptr_conv.is_owned = false;
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33126         LDKPublicKey val_ref;
33127         CHECK(val->arr_len == 33);
33128         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33129         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
33130 }
33131
33132 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) {
33133         LDKPublicKey per_commitment_point_arg_ref;
33134         CHECK(per_commitment_point_arg->arr_len == 33);
33135         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
33136         LDKPublicKey revocation_key_arg_ref;
33137         CHECK(revocation_key_arg->arr_len == 33);
33138         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
33139         LDKPublicKey broadcaster_htlc_key_arg_ref;
33140         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
33141         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
33142         LDKPublicKey countersignatory_htlc_key_arg_ref;
33143         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
33144         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
33145         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
33146         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
33147         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
33148         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);
33149         uint32_t ret_ref = 0;
33150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33153         ret_ref = (uintptr_t)ret_var.inner;
33154         if (ret_var.is_owned) {
33155                 ret_ref |= 1;
33156         }
33157         return ret_ref;
33158 }
33159
33160 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
33161         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
33162 uint32_t ret_ref = 0;
33163 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33164 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33165 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33166 ret_ref = (uintptr_t)ret_var.inner;
33167 if (ret_var.is_owned) {
33168         ret_ref |= 1;
33169 }
33170         return ret_ref;
33171 }
33172 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
33173         LDKTxCreationKeys arg_conv;
33174         arg_conv.inner = (void*)(arg & (~1));
33175         arg_conv.is_owned = false;
33176         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33177         uint32_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
33178         return ret_val;
33179 }
33180
33181 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
33182         LDKTxCreationKeys orig_conv;
33183         orig_conv.inner = (void*)(orig & (~1));
33184         orig_conv.is_owned = false;
33185         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33186         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
33187         uint32_t ret_ref = 0;
33188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33191         ret_ref = (uintptr_t)ret_var.inner;
33192         if (ret_var.is_owned) {
33193                 ret_ref |= 1;
33194         }
33195         return ret_ref;
33196 }
33197
33198 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
33199         LDKTxCreationKeys obj_conv;
33200         obj_conv.inner = (void*)(obj & (~1));
33201         obj_conv.is_owned = false;
33202         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33203         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
33204         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33205         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33206         CVec_u8Z_free(ret_var);
33207         return ret_arr;
33208 }
33209
33210 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
33211         LDKu8slice ser_ref;
33212         ser_ref.datalen = ser->arr_len;
33213         ser_ref.data = ser->elems /* XXX ser leaks */;
33214         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
33215         *ret_conv = TxCreationKeys_read(ser_ref);
33216         return (uint32_t)ret_conv;
33217 }
33218
33219 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
33220         LDKChannelPublicKeys this_obj_conv;
33221         this_obj_conv.inner = (void*)(this_obj & (~1));
33222         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33224         ChannelPublicKeys_free(this_obj_conv);
33225 }
33226
33227 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
33228         LDKChannelPublicKeys this_ptr_conv;
33229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33230         this_ptr_conv.is_owned = false;
33231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33232         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33233         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
33234         return ret_arr;
33235 }
33236
33237 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
33238         LDKChannelPublicKeys this_ptr_conv;
33239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33240         this_ptr_conv.is_owned = false;
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33242         LDKPublicKey val_ref;
33243         CHECK(val->arr_len == 33);
33244         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33245         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
33246 }
33247
33248 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
33249         LDKChannelPublicKeys this_ptr_conv;
33250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33251         this_ptr_conv.is_owned = false;
33252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33253         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33254         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
33255         return ret_arr;
33256 }
33257
33258 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
33259         LDKChannelPublicKeys this_ptr_conv;
33260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33261         this_ptr_conv.is_owned = false;
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33263         LDKPublicKey val_ref;
33264         CHECK(val->arr_len == 33);
33265         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33266         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
33267 }
33268
33269 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
33270         LDKChannelPublicKeys this_ptr_conv;
33271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33272         this_ptr_conv.is_owned = false;
33273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33274         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33275         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
33276         return ret_arr;
33277 }
33278
33279 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
33280         LDKChannelPublicKeys this_ptr_conv;
33281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33282         this_ptr_conv.is_owned = false;
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33284         LDKPublicKey val_ref;
33285         CHECK(val->arr_len == 33);
33286         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33287         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
33288 }
33289
33290 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
33291         LDKChannelPublicKeys this_ptr_conv;
33292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33293         this_ptr_conv.is_owned = false;
33294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33295         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33296         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
33297         return ret_arr;
33298 }
33299
33300 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
33301         LDKChannelPublicKeys this_ptr_conv;
33302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33303         this_ptr_conv.is_owned = false;
33304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33305         LDKPublicKey val_ref;
33306         CHECK(val->arr_len == 33);
33307         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33308         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33309 }
33310
33311 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
33312         LDKChannelPublicKeys this_ptr_conv;
33313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33314         this_ptr_conv.is_owned = false;
33315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33316         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33317         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
33318         return ret_arr;
33319 }
33320
33321 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
33322         LDKChannelPublicKeys this_ptr_conv;
33323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33324         this_ptr_conv.is_owned = false;
33325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33326         LDKPublicKey val_ref;
33327         CHECK(val->arr_len == 33);
33328         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33329         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
33330 }
33331
33332 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) {
33333         LDKPublicKey funding_pubkey_arg_ref;
33334         CHECK(funding_pubkey_arg->arr_len == 33);
33335         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
33336         LDKPublicKey revocation_basepoint_arg_ref;
33337         CHECK(revocation_basepoint_arg->arr_len == 33);
33338         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
33339         LDKPublicKey payment_point_arg_ref;
33340         CHECK(payment_point_arg->arr_len == 33);
33341         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
33342         LDKPublicKey delayed_payment_basepoint_arg_ref;
33343         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
33344         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
33345         LDKPublicKey htlc_basepoint_arg_ref;
33346         CHECK(htlc_basepoint_arg->arr_len == 33);
33347         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
33348         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);
33349         uint32_t ret_ref = 0;
33350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33353         ret_ref = (uintptr_t)ret_var.inner;
33354         if (ret_var.is_owned) {
33355                 ret_ref |= 1;
33356         }
33357         return ret_ref;
33358 }
33359
33360 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
33361         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
33362 uint32_t ret_ref = 0;
33363 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33364 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33365 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33366 ret_ref = (uintptr_t)ret_var.inner;
33367 if (ret_var.is_owned) {
33368         ret_ref |= 1;
33369 }
33370         return ret_ref;
33371 }
33372 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
33373         LDKChannelPublicKeys arg_conv;
33374         arg_conv.inner = (void*)(arg & (~1));
33375         arg_conv.is_owned = false;
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33377         uint32_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
33378         return ret_val;
33379 }
33380
33381 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
33382         LDKChannelPublicKeys orig_conv;
33383         orig_conv.inner = (void*)(orig & (~1));
33384         orig_conv.is_owned = false;
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33386         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
33387         uint32_t ret_ref = 0;
33388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33391         ret_ref = (uintptr_t)ret_var.inner;
33392         if (ret_var.is_owned) {
33393                 ret_ref |= 1;
33394         }
33395         return ret_ref;
33396 }
33397
33398 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
33399         LDKChannelPublicKeys obj_conv;
33400         obj_conv.inner = (void*)(obj & (~1));
33401         obj_conv.is_owned = false;
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33403         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
33404         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33405         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33406         CVec_u8Z_free(ret_var);
33407         return ret_arr;
33408 }
33409
33410 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
33411         LDKu8slice ser_ref;
33412         ser_ref.datalen = ser->arr_len;
33413         ser_ref.data = ser->elems /* XXX ser leaks */;
33414         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
33415         *ret_conv = ChannelPublicKeys_read(ser_ref);
33416         return (uint32_t)ret_conv;
33417 }
33418
33419 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) {
33420         LDKPublicKey per_commitment_point_ref;
33421         CHECK(per_commitment_point->arr_len == 33);
33422         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33423         LDKPublicKey broadcaster_delayed_payment_base_ref;
33424         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
33425         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
33426         LDKPublicKey broadcaster_htlc_base_ref;
33427         CHECK(broadcaster_htlc_base->arr_len == 33);
33428         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
33429         LDKPublicKey countersignatory_revocation_base_ref;
33430         CHECK(countersignatory_revocation_base->arr_len == 33);
33431         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
33432         LDKPublicKey countersignatory_htlc_base_ref;
33433         CHECK(countersignatory_htlc_base->arr_len == 33);
33434         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
33435         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33436         *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);
33437         return (uint32_t)ret_conv;
33438 }
33439
33440 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) {
33441         LDKPublicKey per_commitment_point_ref;
33442         CHECK(per_commitment_point->arr_len == 33);
33443         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33444         LDKChannelPublicKeys broadcaster_keys_conv;
33445         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33446         broadcaster_keys_conv.is_owned = false;
33447         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33448         LDKChannelPublicKeys countersignatory_keys_conv;
33449         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33450         countersignatory_keys_conv.is_owned = false;
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33452         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33453         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
33454         return (uint32_t)ret_conv;
33455 }
33456
33457 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) {
33458         LDKPublicKey revocation_key_ref;
33459         CHECK(revocation_key->arr_len == 33);
33460         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33461         LDKPublicKey broadcaster_delayed_payment_key_ref;
33462         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33463         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33464         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33467         CVec_u8Z_free(ret_var);
33468         return ret_arr;
33469 }
33470
33471 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
33472         LDKHTLCOutputInCommitment this_obj_conv;
33473         this_obj_conv.inner = (void*)(this_obj & (~1));
33474         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33476         HTLCOutputInCommitment_free(this_obj_conv);
33477 }
33478
33479 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
33480         LDKHTLCOutputInCommitment this_ptr_conv;
33481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33482         this_ptr_conv.is_owned = false;
33483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33484         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33485         return ret_val;
33486 }
33487
33488 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
33489         LDKHTLCOutputInCommitment this_ptr_conv;
33490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33491         this_ptr_conv.is_owned = false;
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33493         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33494 }
33495
33496 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
33497         LDKHTLCOutputInCommitment this_ptr_conv;
33498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33499         this_ptr_conv.is_owned = false;
33500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33501         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33502         return ret_val;
33503 }
33504
33505 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
33506         LDKHTLCOutputInCommitment this_ptr_conv;
33507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33508         this_ptr_conv.is_owned = false;
33509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33510         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33511 }
33512
33513 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
33514         LDKHTLCOutputInCommitment this_ptr_conv;
33515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33516         this_ptr_conv.is_owned = false;
33517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33518         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33519         return ret_val;
33520 }
33521
33522 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
33523         LDKHTLCOutputInCommitment this_ptr_conv;
33524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33525         this_ptr_conv.is_owned = false;
33526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33527         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33528 }
33529
33530 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
33531         LDKHTLCOutputInCommitment this_ptr_conv;
33532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33533         this_ptr_conv.is_owned = false;
33534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33535         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33536         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
33537         return ret_arr;
33538 }
33539
33540 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
33541         LDKHTLCOutputInCommitment this_ptr_conv;
33542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33543         this_ptr_conv.is_owned = false;
33544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33545         LDKThirtyTwoBytes val_ref;
33546         CHECK(val->arr_len == 32);
33547         memcpy(val_ref.data, val->elems, 32); FREE(val);
33548         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33549 }
33550
33551 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
33552         LDKHTLCOutputInCommitment this_ptr_conv;
33553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33554         this_ptr_conv.is_owned = false;
33555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33556         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33557         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33558         uint32_t ret_ref = (uintptr_t)ret_copy;
33559         return ret_ref;
33560 }
33561
33562 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
33563         LDKHTLCOutputInCommitment this_ptr_conv;
33564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33565         this_ptr_conv.is_owned = false;
33566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33567         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33568         CHECK_ACCESS(val_ptr);
33569         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33570         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
33571         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33572 }
33573
33574 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) {
33575         LDKThirtyTwoBytes payment_hash_arg_ref;
33576         CHECK(payment_hash_arg->arr_len == 32);
33577         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
33578         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
33579         CHECK_ACCESS(transaction_output_index_arg_ptr);
33580         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33581         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
33582         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33583         uint32_t ret_ref = 0;
33584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33587         ret_ref = (uintptr_t)ret_var.inner;
33588         if (ret_var.is_owned) {
33589                 ret_ref |= 1;
33590         }
33591         return ret_ref;
33592 }
33593
33594 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33595         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33596 uint32_t ret_ref = 0;
33597 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33598 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33599 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33600 ret_ref = (uintptr_t)ret_var.inner;
33601 if (ret_var.is_owned) {
33602         ret_ref |= 1;
33603 }
33604         return ret_ref;
33605 }
33606 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33607         LDKHTLCOutputInCommitment arg_conv;
33608         arg_conv.inner = (void*)(arg & (~1));
33609         arg_conv.is_owned = false;
33610         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33611         uint32_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33612         return ret_val;
33613 }
33614
33615 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33616         LDKHTLCOutputInCommitment orig_conv;
33617         orig_conv.inner = (void*)(orig & (~1));
33618         orig_conv.is_owned = false;
33619         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33620         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33621         uint32_t ret_ref = 0;
33622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33625         ret_ref = (uintptr_t)ret_var.inner;
33626         if (ret_var.is_owned) {
33627                 ret_ref |= 1;
33628         }
33629         return ret_ref;
33630 }
33631
33632 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33633         LDKHTLCOutputInCommitment obj_conv;
33634         obj_conv.inner = (void*)(obj & (~1));
33635         obj_conv.is_owned = false;
33636         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33637         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33638         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33639         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33640         CVec_u8Z_free(ret_var);
33641         return ret_arr;
33642 }
33643
33644 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33645         LDKu8slice ser_ref;
33646         ser_ref.datalen = ser->arr_len;
33647         ser_ref.data = ser->elems /* XXX ser leaks */;
33648         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33649         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33650         return (uint32_t)ret_conv;
33651 }
33652
33653 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33654         LDKHTLCOutputInCommitment htlc_conv;
33655         htlc_conv.inner = (void*)(htlc & (~1));
33656         htlc_conv.is_owned = false;
33657         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33658         LDKTxCreationKeys keys_conv;
33659         keys_conv.inner = (void*)(keys & (~1));
33660         keys_conv.is_owned = false;
33661         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33662         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33663         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33664         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33665         CVec_u8Z_free(ret_var);
33666         return ret_arr;
33667 }
33668
33669 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33670         LDKPublicKey broadcaster_ref;
33671         CHECK(broadcaster->arr_len == 33);
33672         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33673         LDKPublicKey countersignatory_ref;
33674         CHECK(countersignatory->arr_len == 33);
33675         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33676         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33677         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33678         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33679         CVec_u8Z_free(ret_var);
33680         return ret_arr;
33681 }
33682
33683 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) {
33684         unsigned char commitment_txid_arr[32];
33685         CHECK(commitment_txid->arr_len == 32);
33686         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33687         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33688         LDKHTLCOutputInCommitment htlc_conv;
33689         htlc_conv.inner = (void*)(htlc & (~1));
33690         htlc_conv.is_owned = false;
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33692         LDKPublicKey broadcaster_delayed_payment_key_ref;
33693         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33694         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33695         LDKPublicKey revocation_key_ref;
33696         CHECK(revocation_key->arr_len == 33);
33697         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33698         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);
33699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33701         Transaction_free(ret_var);
33702         return ret_arr;
33703 }
33704
33705 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33706         LDKPublicKey funding_pubkey_ref;
33707         CHECK(funding_pubkey->arr_len == 33);
33708         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33709         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33710         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33711         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33712         CVec_u8Z_free(ret_var);
33713         return ret_arr;
33714 }
33715
33716 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33717         LDKChannelTransactionParameters this_obj_conv;
33718         this_obj_conv.inner = (void*)(this_obj & (~1));
33719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33721         ChannelTransactionParameters_free(this_obj_conv);
33722 }
33723
33724 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33725         LDKChannelTransactionParameters this_ptr_conv;
33726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33727         this_ptr_conv.is_owned = false;
33728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33729         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33730         uint32_t ret_ref = 0;
33731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33734         ret_ref = (uintptr_t)ret_var.inner;
33735         if (ret_var.is_owned) {
33736                 ret_ref |= 1;
33737         }
33738         return ret_ref;
33739 }
33740
33741 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33742         LDKChannelTransactionParameters this_ptr_conv;
33743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33744         this_ptr_conv.is_owned = false;
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33746         LDKChannelPublicKeys val_conv;
33747         val_conv.inner = (void*)(val & (~1));
33748         val_conv.is_owned = (val & 1) || (val == 0);
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33750         val_conv = ChannelPublicKeys_clone(&val_conv);
33751         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33752 }
33753
33754 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33755         LDKChannelTransactionParameters this_ptr_conv;
33756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33757         this_ptr_conv.is_owned = false;
33758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33759         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33760         return ret_val;
33761 }
33762
33763 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) {
33764         LDKChannelTransactionParameters this_ptr_conv;
33765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33766         this_ptr_conv.is_owned = false;
33767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33768         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33769 }
33770
33771 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33772         LDKChannelTransactionParameters this_ptr_conv;
33773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33774         this_ptr_conv.is_owned = false;
33775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33776         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33777         return ret_val;
33778 }
33779
33780 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33781         LDKChannelTransactionParameters this_ptr_conv;
33782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33783         this_ptr_conv.is_owned = false;
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33785         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33786 }
33787
33788 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33789         LDKChannelTransactionParameters this_ptr_conv;
33790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33791         this_ptr_conv.is_owned = false;
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33793         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33794         uint32_t ret_ref = 0;
33795         if ((uintptr_t)ret_var.inner > 4096) {
33796                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33797                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33799                 ret_ref = (uintptr_t)ret_var.inner;
33800                 if (ret_var.is_owned) {
33801                         ret_ref |= 1;
33802                 }
33803         }
33804         return ret_ref;
33805 }
33806
33807 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33808         LDKChannelTransactionParameters this_ptr_conv;
33809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33810         this_ptr_conv.is_owned = false;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33812         LDKCounterpartyChannelTransactionParameters val_conv;
33813         val_conv.inner = (void*)(val & (~1));
33814         val_conv.is_owned = (val & 1) || (val == 0);
33815         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33816         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33817         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33818 }
33819
33820 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33821         LDKChannelTransactionParameters this_ptr_conv;
33822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33823         this_ptr_conv.is_owned = false;
33824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33825         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33826         uint32_t ret_ref = 0;
33827         if ((uintptr_t)ret_var.inner > 4096) {
33828                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33829                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33831                 ret_ref = (uintptr_t)ret_var.inner;
33832                 if (ret_var.is_owned) {
33833                         ret_ref |= 1;
33834                 }
33835         }
33836         return ret_ref;
33837 }
33838
33839 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33840         LDKChannelTransactionParameters this_ptr_conv;
33841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33842         this_ptr_conv.is_owned = false;
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33844         LDKOutPoint val_conv;
33845         val_conv.inner = (void*)(val & (~1));
33846         val_conv.is_owned = (val & 1) || (val == 0);
33847         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33848         val_conv = OutPoint_clone(&val_conv);
33849         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33850 }
33851
33852 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33853         LDKChannelTransactionParameters this_ptr_conv;
33854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33855         this_ptr_conv.is_owned = false;
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33857         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33858         return ret_conv;
33859 }
33860
33861 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33862         LDKChannelTransactionParameters this_ptr_conv;
33863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33864         this_ptr_conv.is_owned = false;
33865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33866         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33867         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33868 }
33869
33870 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) {
33871         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33872         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33873         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33875         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33876         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33877         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33878         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33879         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33880         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33881         LDKOutPoint funding_outpoint_arg_conv;
33882         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33883         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33884         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33885         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33886         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33887         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);
33888         uint32_t ret_ref = 0;
33889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33892         ret_ref = (uintptr_t)ret_var.inner;
33893         if (ret_var.is_owned) {
33894                 ret_ref |= 1;
33895         }
33896         return ret_ref;
33897 }
33898
33899 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33900         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33901 uint32_t ret_ref = 0;
33902 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33903 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33904 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33905 ret_ref = (uintptr_t)ret_var.inner;
33906 if (ret_var.is_owned) {
33907         ret_ref |= 1;
33908 }
33909         return ret_ref;
33910 }
33911 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33912         LDKChannelTransactionParameters arg_conv;
33913         arg_conv.inner = (void*)(arg & (~1));
33914         arg_conv.is_owned = false;
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33916         uint32_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33917         return ret_val;
33918 }
33919
33920 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33921         LDKChannelTransactionParameters orig_conv;
33922         orig_conv.inner = (void*)(orig & (~1));
33923         orig_conv.is_owned = false;
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33925         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33926         uint32_t ret_ref = 0;
33927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33930         ret_ref = (uintptr_t)ret_var.inner;
33931         if (ret_var.is_owned) {
33932                 ret_ref |= 1;
33933         }
33934         return ret_ref;
33935 }
33936
33937 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33938         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33939         this_obj_conv.inner = (void*)(this_obj & (~1));
33940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33942         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33943 }
33944
33945 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
33946         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33948         this_ptr_conv.is_owned = false;
33949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33950         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
33951         uint32_t ret_ref = 0;
33952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33955         ret_ref = (uintptr_t)ret_var.inner;
33956         if (ret_var.is_owned) {
33957                 ret_ref |= 1;
33958         }
33959         return ret_ref;
33960 }
33961
33962 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
33963         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33965         this_ptr_conv.is_owned = false;
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33967         LDKChannelPublicKeys val_conv;
33968         val_conv.inner = (void*)(val & (~1));
33969         val_conv.is_owned = (val & 1) || (val == 0);
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33971         val_conv = ChannelPublicKeys_clone(&val_conv);
33972         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33973 }
33974
33975 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
33976         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33978         this_ptr_conv.is_owned = false;
33979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33980         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33981         return ret_val;
33982 }
33983
33984 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
33985         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33987         this_ptr_conv.is_owned = false;
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33989         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33990 }
33991
33992 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
33993         LDKChannelPublicKeys pubkeys_arg_conv;
33994         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33995         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33996         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33997         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33998         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33999         uint32_t ret_ref = 0;
34000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34003         ret_ref = (uintptr_t)ret_var.inner;
34004         if (ret_var.is_owned) {
34005                 ret_ref |= 1;
34006         }
34007         return ret_ref;
34008 }
34009
34010 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
34011         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
34012 uint32_t ret_ref = 0;
34013 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34014 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34015 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34016 ret_ref = (uintptr_t)ret_var.inner;
34017 if (ret_var.is_owned) {
34018         ret_ref |= 1;
34019 }
34020         return ret_ref;
34021 }
34022 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
34023         LDKCounterpartyChannelTransactionParameters arg_conv;
34024         arg_conv.inner = (void*)(arg & (~1));
34025         arg_conv.is_owned = false;
34026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34027         uint32_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
34028         return ret_val;
34029 }
34030
34031 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
34032         LDKCounterpartyChannelTransactionParameters orig_conv;
34033         orig_conv.inner = (void*)(orig & (~1));
34034         orig_conv.is_owned = false;
34035         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34036         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
34037         uint32_t ret_ref = 0;
34038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34041         ret_ref = (uintptr_t)ret_var.inner;
34042         if (ret_var.is_owned) {
34043                 ret_ref |= 1;
34044         }
34045         return ret_ref;
34046 }
34047
34048 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
34049         LDKChannelTransactionParameters this_arg_conv;
34050         this_arg_conv.inner = (void*)(this_arg & (~1));
34051         this_arg_conv.is_owned = false;
34052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34053         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
34054         return ret_val;
34055 }
34056
34057 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
34058         LDKChannelTransactionParameters this_arg_conv;
34059         this_arg_conv.inner = (void*)(this_arg & (~1));
34060         this_arg_conv.is_owned = false;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34062         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
34063         uint32_t ret_ref = 0;
34064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34067         ret_ref = (uintptr_t)ret_var.inner;
34068         if (ret_var.is_owned) {
34069                 ret_ref |= 1;
34070         }
34071         return ret_ref;
34072 }
34073
34074 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
34075         LDKChannelTransactionParameters this_arg_conv;
34076         this_arg_conv.inner = (void*)(this_arg & (~1));
34077         this_arg_conv.is_owned = false;
34078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34079         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
34080         uint32_t ret_ref = 0;
34081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34084         ret_ref = (uintptr_t)ret_var.inner;
34085         if (ret_var.is_owned) {
34086                 ret_ref |= 1;
34087         }
34088         return ret_ref;
34089 }
34090
34091 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
34092         LDKCounterpartyChannelTransactionParameters obj_conv;
34093         obj_conv.inner = (void*)(obj & (~1));
34094         obj_conv.is_owned = false;
34095         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34096         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
34097         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34098         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34099         CVec_u8Z_free(ret_var);
34100         return ret_arr;
34101 }
34102
34103 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
34104         LDKu8slice ser_ref;
34105         ser_ref.datalen = ser->arr_len;
34106         ser_ref.data = ser->elems /* XXX ser leaks */;
34107         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
34108         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
34109         return (uint32_t)ret_conv;
34110 }
34111
34112 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
34113         LDKChannelTransactionParameters obj_conv;
34114         obj_conv.inner = (void*)(obj & (~1));
34115         obj_conv.is_owned = false;
34116         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34117         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
34118         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34119         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34120         CVec_u8Z_free(ret_var);
34121         return ret_arr;
34122 }
34123
34124 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
34125         LDKu8slice ser_ref;
34126         ser_ref.datalen = ser->arr_len;
34127         ser_ref.data = ser->elems /* XXX ser leaks */;
34128         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
34129         *ret_conv = ChannelTransactionParameters_read(ser_ref);
34130         return (uint32_t)ret_conv;
34131 }
34132
34133 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
34134         LDKDirectedChannelTransactionParameters this_obj_conv;
34135         this_obj_conv.inner = (void*)(this_obj & (~1));
34136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34138         DirectedChannelTransactionParameters_free(this_obj_conv);
34139 }
34140
34141 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
34142         LDKDirectedChannelTransactionParameters this_arg_conv;
34143         this_arg_conv.inner = (void*)(this_arg & (~1));
34144         this_arg_conv.is_owned = false;
34145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34146         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
34147         uint32_t ret_ref = 0;
34148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34151         ret_ref = (uintptr_t)ret_var.inner;
34152         if (ret_var.is_owned) {
34153                 ret_ref |= 1;
34154         }
34155         return ret_ref;
34156 }
34157
34158 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
34159         LDKDirectedChannelTransactionParameters this_arg_conv;
34160         this_arg_conv.inner = (void*)(this_arg & (~1));
34161         this_arg_conv.is_owned = false;
34162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34163         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
34164         uint32_t ret_ref = 0;
34165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34168         ret_ref = (uintptr_t)ret_var.inner;
34169         if (ret_var.is_owned) {
34170                 ret_ref |= 1;
34171         }
34172         return ret_ref;
34173 }
34174
34175 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
34176         LDKDirectedChannelTransactionParameters this_arg_conv;
34177         this_arg_conv.inner = (void*)(this_arg & (~1));
34178         this_arg_conv.is_owned = false;
34179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34180         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
34181         return ret_val;
34182 }
34183
34184 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
34185         LDKDirectedChannelTransactionParameters this_arg_conv;
34186         this_arg_conv.inner = (void*)(this_arg & (~1));
34187         this_arg_conv.is_owned = false;
34188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34189         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
34190         return ret_val;
34191 }
34192
34193 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
34194         LDKDirectedChannelTransactionParameters this_arg_conv;
34195         this_arg_conv.inner = (void*)(this_arg & (~1));
34196         this_arg_conv.is_owned = false;
34197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34198         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
34199         uint32_t ret_ref = 0;
34200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34203         ret_ref = (uintptr_t)ret_var.inner;
34204         if (ret_var.is_owned) {
34205                 ret_ref |= 1;
34206         }
34207         return ret_ref;
34208 }
34209
34210 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
34211         LDKDirectedChannelTransactionParameters this_arg_conv;
34212         this_arg_conv.inner = (void*)(this_arg & (~1));
34213         this_arg_conv.is_owned = false;
34214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34215         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
34216         return ret_val;
34217 }
34218
34219 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
34220         LDKHolderCommitmentTransaction this_obj_conv;
34221         this_obj_conv.inner = (void*)(this_obj & (~1));
34222         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34224         HolderCommitmentTransaction_free(this_obj_conv);
34225 }
34226
34227 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
34228         LDKHolderCommitmentTransaction this_ptr_conv;
34229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34230         this_ptr_conv.is_owned = false;
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34232         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34233         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
34234         return ret_arr;
34235 }
34236
34237 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
34238         LDKHolderCommitmentTransaction this_ptr_conv;
34239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34240         this_ptr_conv.is_owned = false;
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34242         LDKSignature val_ref;
34243         CHECK(val->arr_len == 64);
34244         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
34245         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
34246 }
34247
34248 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
34249         LDKHolderCommitmentTransaction this_ptr_conv;
34250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34251         this_ptr_conv.is_owned = false;
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34253         LDKCVec_SignatureZ val_constr;
34254         val_constr.datalen = val->arr_len;
34255         if (val_constr.datalen > 0)
34256                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34257         else
34258                 val_constr.data = NULL;
34259         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
34260         for (size_t m = 0; m < val_constr.datalen; m++) {
34261                 int8_tArray val_conv_12 = val_vals[m];
34262                 LDKSignature val_conv_12_ref;
34263                 CHECK(val_conv_12->arr_len == 64);
34264                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
34265                 val_constr.data[m] = val_conv_12_ref;
34266         }
34267         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
34268 }
34269
34270 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
34271         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
34272 uint32_t ret_ref = 0;
34273 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34274 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34275 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34276 ret_ref = (uintptr_t)ret_var.inner;
34277 if (ret_var.is_owned) {
34278         ret_ref |= 1;
34279 }
34280         return ret_ref;
34281 }
34282 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
34283         LDKHolderCommitmentTransaction arg_conv;
34284         arg_conv.inner = (void*)(arg & (~1));
34285         arg_conv.is_owned = false;
34286         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34287         uint32_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
34288         return ret_val;
34289 }
34290
34291 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
34292         LDKHolderCommitmentTransaction orig_conv;
34293         orig_conv.inner = (void*)(orig & (~1));
34294         orig_conv.is_owned = false;
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34296         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
34297         uint32_t ret_ref = 0;
34298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34301         ret_ref = (uintptr_t)ret_var.inner;
34302         if (ret_var.is_owned) {
34303                 ret_ref |= 1;
34304         }
34305         return ret_ref;
34306 }
34307
34308 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
34309         LDKHolderCommitmentTransaction obj_conv;
34310         obj_conv.inner = (void*)(obj & (~1));
34311         obj_conv.is_owned = false;
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34313         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
34314         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34315         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34316         CVec_u8Z_free(ret_var);
34317         return ret_arr;
34318 }
34319
34320 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
34321         LDKu8slice ser_ref;
34322         ser_ref.datalen = ser->arr_len;
34323         ser_ref.data = ser->elems /* XXX ser leaks */;
34324         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
34325         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
34326         return (uint32_t)ret_conv;
34327 }
34328
34329 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) {
34330         LDKCommitmentTransaction commitment_tx_conv;
34331         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
34332         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
34333         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
34334         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
34335         LDKSignature counterparty_sig_ref;
34336         CHECK(counterparty_sig->arr_len == 64);
34337         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
34338         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
34339         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
34340         if (counterparty_htlc_sigs_constr.datalen > 0)
34341                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34342         else
34343                 counterparty_htlc_sigs_constr.data = NULL;
34344         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
34345         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
34346                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
34347                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
34348                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
34349                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
34350                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
34351         }
34352         LDKPublicKey holder_funding_key_ref;
34353         CHECK(holder_funding_key->arr_len == 33);
34354         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
34355         LDKPublicKey counterparty_funding_key_ref;
34356         CHECK(counterparty_funding_key->arr_len == 33);
34357         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
34358         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
34359         uint32_t ret_ref = 0;
34360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34363         ret_ref = (uintptr_t)ret_var.inner;
34364         if (ret_var.is_owned) {
34365                 ret_ref |= 1;
34366         }
34367         return ret_ref;
34368 }
34369
34370 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
34371         LDKBuiltCommitmentTransaction this_obj_conv;
34372         this_obj_conv.inner = (void*)(this_obj & (~1));
34373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34375         BuiltCommitmentTransaction_free(this_obj_conv);
34376 }
34377
34378 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
34379         LDKBuiltCommitmentTransaction this_ptr_conv;
34380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34381         this_ptr_conv.is_owned = false;
34382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34383         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
34384         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34385         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34386         Transaction_free(ret_var);
34387         return ret_arr;
34388 }
34389
34390 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
34391         LDKBuiltCommitmentTransaction this_ptr_conv;
34392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34393         this_ptr_conv.is_owned = false;
34394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34395         LDKTransaction val_ref;
34396         val_ref.datalen = val->arr_len;
34397         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
34398         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
34399         val_ref.data_is_owned = true;
34400         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
34401 }
34402
34403 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
34404         LDKBuiltCommitmentTransaction this_ptr_conv;
34405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34406         this_ptr_conv.is_owned = false;
34407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34408         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34409         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
34410         return ret_arr;
34411 }
34412
34413 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
34414         LDKBuiltCommitmentTransaction this_ptr_conv;
34415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34416         this_ptr_conv.is_owned = false;
34417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34418         LDKThirtyTwoBytes val_ref;
34419         CHECK(val->arr_len == 32);
34420         memcpy(val_ref.data, val->elems, 32); FREE(val);
34421         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
34422 }
34423
34424 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
34425         LDKTransaction transaction_arg_ref;
34426         transaction_arg_ref.datalen = transaction_arg->arr_len;
34427         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
34428         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
34429         transaction_arg_ref.data_is_owned = true;
34430         LDKThirtyTwoBytes txid_arg_ref;
34431         CHECK(txid_arg->arr_len == 32);
34432         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
34433         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
34434         uint32_t ret_ref = 0;
34435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34438         ret_ref = (uintptr_t)ret_var.inner;
34439         if (ret_var.is_owned) {
34440                 ret_ref |= 1;
34441         }
34442         return ret_ref;
34443 }
34444
34445 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
34446         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
34447 uint32_t ret_ref = 0;
34448 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34449 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34451 ret_ref = (uintptr_t)ret_var.inner;
34452 if (ret_var.is_owned) {
34453         ret_ref |= 1;
34454 }
34455         return ret_ref;
34456 }
34457 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
34458         LDKBuiltCommitmentTransaction arg_conv;
34459         arg_conv.inner = (void*)(arg & (~1));
34460         arg_conv.is_owned = false;
34461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34462         uint32_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34463         return ret_val;
34464 }
34465
34466 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
34467         LDKBuiltCommitmentTransaction orig_conv;
34468         orig_conv.inner = (void*)(orig & (~1));
34469         orig_conv.is_owned = false;
34470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34471         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34472         uint32_t ret_ref = 0;
34473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34476         ret_ref = (uintptr_t)ret_var.inner;
34477         if (ret_var.is_owned) {
34478                 ret_ref |= 1;
34479         }
34480         return ret_ref;
34481 }
34482
34483 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
34484         LDKBuiltCommitmentTransaction obj_conv;
34485         obj_conv.inner = (void*)(obj & (~1));
34486         obj_conv.is_owned = false;
34487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34488         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34489         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34490         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34491         CVec_u8Z_free(ret_var);
34492         return ret_arr;
34493 }
34494
34495 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
34496         LDKu8slice ser_ref;
34497         ser_ref.datalen = ser->arr_len;
34498         ser_ref.data = ser->elems /* XXX ser leaks */;
34499         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34500         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34501         return (uint32_t)ret_conv;
34502 }
34503
34504 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) {
34505         LDKBuiltCommitmentTransaction this_arg_conv;
34506         this_arg_conv.inner = (void*)(this_arg & (~1));
34507         this_arg_conv.is_owned = false;
34508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34509         LDKu8slice funding_redeemscript_ref;
34510         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34511         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34512         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34513         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34514         return ret_arr;
34515 }
34516
34517 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) {
34518         LDKBuiltCommitmentTransaction this_arg_conv;
34519         this_arg_conv.inner = (void*)(this_arg & (~1));
34520         this_arg_conv.is_owned = false;
34521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34522         unsigned char funding_key_arr[32];
34523         CHECK(funding_key->arr_len == 32);
34524         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34525         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34526         LDKu8slice funding_redeemscript_ref;
34527         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34528         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34529         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34530         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34531         return ret_arr;
34532 }
34533
34534 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
34535         LDKClosingTransaction this_obj_conv;
34536         this_obj_conv.inner = (void*)(this_obj & (~1));
34537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34539         ClosingTransaction_free(this_obj_conv);
34540 }
34541
34542 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34543         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34544 uint32_t ret_ref = 0;
34545 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34546 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34547 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34548 ret_ref = (uintptr_t)ret_var.inner;
34549 if (ret_var.is_owned) {
34550         ret_ref |= 1;
34551 }
34552         return ret_ref;
34553 }
34554 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
34555         LDKClosingTransaction arg_conv;
34556         arg_conv.inner = (void*)(arg & (~1));
34557         arg_conv.is_owned = false;
34558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34559         uint32_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
34560         return ret_val;
34561 }
34562
34563 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
34564         LDKClosingTransaction orig_conv;
34565         orig_conv.inner = (void*)(orig & (~1));
34566         orig_conv.is_owned = false;
34567         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34568         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34569         uint32_t ret_ref = 0;
34570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34573         ret_ref = (uintptr_t)ret_var.inner;
34574         if (ret_var.is_owned) {
34575                 ret_ref |= 1;
34576         }
34577         return ret_ref;
34578 }
34579
34580 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
34581         LDKClosingTransaction o_conv;
34582         o_conv.inner = (void*)(o & (~1));
34583         o_conv.is_owned = false;
34584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34585         int64_t ret_val = ClosingTransaction_hash(&o_conv);
34586         return ret_val;
34587 }
34588
34589 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) {
34590         LDKCVec_u8Z to_holder_script_ref;
34591         to_holder_script_ref.datalen = to_holder_script->arr_len;
34592         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34593         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34594         LDKCVec_u8Z to_counterparty_script_ref;
34595         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34596         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34597         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34598         LDKOutPoint funding_outpoint_conv;
34599         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34600         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34602         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34603         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34604         uint32_t ret_ref = 0;
34605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34608         ret_ref = (uintptr_t)ret_var.inner;
34609         if (ret_var.is_owned) {
34610                 ret_ref |= 1;
34611         }
34612         return ret_ref;
34613 }
34614
34615 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34616         LDKClosingTransaction this_arg_conv;
34617         this_arg_conv.inner = (void*)(this_arg & (~1));
34618         this_arg_conv.is_owned = false;
34619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34620         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34621         uint32_t ret_ref = 0;
34622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34625         ret_ref = (uintptr_t)ret_var.inner;
34626         if (ret_var.is_owned) {
34627                 ret_ref |= 1;
34628         }
34629         return ret_ref;
34630 }
34631
34632 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34633         LDKClosingTransaction this_arg_conv;
34634         this_arg_conv.inner = (void*)(this_arg & (~1));
34635         this_arg_conv.is_owned = false;
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34637         LDKOutPoint funding_outpoint_conv;
34638         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34639         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34640         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34641         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34642         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34643         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34644         return (uint32_t)ret_conv;
34645 }
34646
34647 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34648         LDKClosingTransaction this_arg_conv;
34649         this_arg_conv.inner = (void*)(this_arg & (~1));
34650         this_arg_conv.is_owned = false;
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34652         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34653         return ret_val;
34654 }
34655
34656 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34657         LDKClosingTransaction this_arg_conv;
34658         this_arg_conv.inner = (void*)(this_arg & (~1));
34659         this_arg_conv.is_owned = false;
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34661         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34662         return ret_val;
34663 }
34664
34665 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34666         LDKClosingTransaction this_arg_conv;
34667         this_arg_conv.inner = (void*)(this_arg & (~1));
34668         this_arg_conv.is_owned = false;
34669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34670         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34671         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34672         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34673         return ret_arr;
34674 }
34675
34676 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34677         LDKClosingTransaction this_arg_conv;
34678         this_arg_conv.inner = (void*)(this_arg & (~1));
34679         this_arg_conv.is_owned = false;
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34681         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34682         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34683         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34684         return ret_arr;
34685 }
34686
34687 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34688         LDKTrustedClosingTransaction this_obj_conv;
34689         this_obj_conv.inner = (void*)(this_obj & (~1));
34690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34692         TrustedClosingTransaction_free(this_obj_conv);
34693 }
34694
34695 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34696         LDKTrustedClosingTransaction this_arg_conv;
34697         this_arg_conv.inner = (void*)(this_arg & (~1));
34698         this_arg_conv.is_owned = false;
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34700         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34701         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34702         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34703         Transaction_free(ret_var);
34704         return ret_arr;
34705 }
34706
34707 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) {
34708         LDKTrustedClosingTransaction this_arg_conv;
34709         this_arg_conv.inner = (void*)(this_arg & (~1));
34710         this_arg_conv.is_owned = false;
34711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34712         LDKu8slice funding_redeemscript_ref;
34713         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34714         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34715         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34716         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34717         return ret_arr;
34718 }
34719
34720 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) {
34721         LDKTrustedClosingTransaction this_arg_conv;
34722         this_arg_conv.inner = (void*)(this_arg & (~1));
34723         this_arg_conv.is_owned = false;
34724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34725         unsigned char funding_key_arr[32];
34726         CHECK(funding_key->arr_len == 32);
34727         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34728         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34729         LDKu8slice funding_redeemscript_ref;
34730         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34731         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34732         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34733         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34734         return ret_arr;
34735 }
34736
34737 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34738         LDKCommitmentTransaction this_obj_conv;
34739         this_obj_conv.inner = (void*)(this_obj & (~1));
34740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34742         CommitmentTransaction_free(this_obj_conv);
34743 }
34744
34745 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34746         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34747 uint32_t ret_ref = 0;
34748 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34749 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34750 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34751 ret_ref = (uintptr_t)ret_var.inner;
34752 if (ret_var.is_owned) {
34753         ret_ref |= 1;
34754 }
34755         return ret_ref;
34756 }
34757 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34758         LDKCommitmentTransaction arg_conv;
34759         arg_conv.inner = (void*)(arg & (~1));
34760         arg_conv.is_owned = false;
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34762         uint32_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34763         return ret_val;
34764 }
34765
34766 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34767         LDKCommitmentTransaction orig_conv;
34768         orig_conv.inner = (void*)(orig & (~1));
34769         orig_conv.is_owned = false;
34770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34771         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34772         uint32_t ret_ref = 0;
34773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34776         ret_ref = (uintptr_t)ret_var.inner;
34777         if (ret_var.is_owned) {
34778                 ret_ref |= 1;
34779         }
34780         return ret_ref;
34781 }
34782
34783 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34784         LDKCommitmentTransaction obj_conv;
34785         obj_conv.inner = (void*)(obj & (~1));
34786         obj_conv.is_owned = false;
34787         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34788         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34789         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34790         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34791         CVec_u8Z_free(ret_var);
34792         return ret_arr;
34793 }
34794
34795 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34796         LDKu8slice ser_ref;
34797         ser_ref.datalen = ser->arr_len;
34798         ser_ref.data = ser->elems /* XXX ser leaks */;
34799         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34800         *ret_conv = CommitmentTransaction_read(ser_ref);
34801         return (uint32_t)ret_conv;
34802 }
34803
34804 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34805         LDKCommitmentTransaction this_arg_conv;
34806         this_arg_conv.inner = (void*)(this_arg & (~1));
34807         this_arg_conv.is_owned = false;
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34809         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34810         return ret_val;
34811 }
34812
34813 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34814         LDKCommitmentTransaction this_arg_conv;
34815         this_arg_conv.inner = (void*)(this_arg & (~1));
34816         this_arg_conv.is_owned = false;
34817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34818         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34819         return ret_val;
34820 }
34821
34822 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34823         LDKCommitmentTransaction this_arg_conv;
34824         this_arg_conv.inner = (void*)(this_arg & (~1));
34825         this_arg_conv.is_owned = false;
34826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34827         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34828         return ret_val;
34829 }
34830
34831 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34832         LDKCommitmentTransaction this_arg_conv;
34833         this_arg_conv.inner = (void*)(this_arg & (~1));
34834         this_arg_conv.is_owned = false;
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34836         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34837         return ret_val;
34838 }
34839
34840 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34841         LDKCommitmentTransaction this_arg_conv;
34842         this_arg_conv.inner = (void*)(this_arg & (~1));
34843         this_arg_conv.is_owned = false;
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34845         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34846         uint32_t ret_ref = 0;
34847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34850         ret_ref = (uintptr_t)ret_var.inner;
34851         if (ret_var.is_owned) {
34852                 ret_ref |= 1;
34853         }
34854         return ret_ref;
34855 }
34856
34857 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) {
34858         LDKCommitmentTransaction this_arg_conv;
34859         this_arg_conv.inner = (void*)(this_arg & (~1));
34860         this_arg_conv.is_owned = false;
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34862         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34863         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34864         channel_parameters_conv.is_owned = false;
34865         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34866         LDKChannelPublicKeys broadcaster_keys_conv;
34867         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34868         broadcaster_keys_conv.is_owned = false;
34869         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34870         LDKChannelPublicKeys countersignatory_keys_conv;
34871         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34872         countersignatory_keys_conv.is_owned = false;
34873         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34874         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34875         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34876         return (uint32_t)ret_conv;
34877 }
34878
34879 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34880         LDKTrustedCommitmentTransaction this_obj_conv;
34881         this_obj_conv.inner = (void*)(this_obj & (~1));
34882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34884         TrustedCommitmentTransaction_free(this_obj_conv);
34885 }
34886
34887 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34888         LDKTrustedCommitmentTransaction this_arg_conv;
34889         this_arg_conv.inner = (void*)(this_arg & (~1));
34890         this_arg_conv.is_owned = false;
34891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34892         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34893         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34894         return ret_arr;
34895 }
34896
34897 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34898         LDKTrustedCommitmentTransaction this_arg_conv;
34899         this_arg_conv.inner = (void*)(this_arg & (~1));
34900         this_arg_conv.is_owned = false;
34901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34902         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34903         uint32_t ret_ref = 0;
34904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34907         ret_ref = (uintptr_t)ret_var.inner;
34908         if (ret_var.is_owned) {
34909                 ret_ref |= 1;
34910         }
34911         return ret_ref;
34912 }
34913
34914 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34915         LDKTrustedCommitmentTransaction this_arg_conv;
34916         this_arg_conv.inner = (void*)(this_arg & (~1));
34917         this_arg_conv.is_owned = false;
34918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34919         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34920         uint32_t ret_ref = 0;
34921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34924         ret_ref = (uintptr_t)ret_var.inner;
34925         if (ret_var.is_owned) {
34926                 ret_ref |= 1;
34927         }
34928         return ret_ref;
34929 }
34930
34931 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34932         LDKTrustedCommitmentTransaction this_arg_conv;
34933         this_arg_conv.inner = (void*)(this_arg & (~1));
34934         this_arg_conv.is_owned = false;
34935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34936         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34937         return ret_val;
34938 }
34939
34940 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) {
34941         LDKTrustedCommitmentTransaction this_arg_conv;
34942         this_arg_conv.inner = (void*)(this_arg & (~1));
34943         this_arg_conv.is_owned = false;
34944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34945         unsigned char htlc_base_key_arr[32];
34946         CHECK(htlc_base_key->arr_len == 32);
34947         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
34948         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34949         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34950         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34951         channel_parameters_conv.is_owned = false;
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34953         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34954         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34955         return (uint32_t)ret_conv;
34956 }
34957
34958 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) {
34959         LDKPublicKey broadcaster_payment_basepoint_ref;
34960         CHECK(broadcaster_payment_basepoint->arr_len == 33);
34961         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
34962         LDKPublicKey countersignatory_payment_basepoint_ref;
34963         CHECK(countersignatory_payment_basepoint->arr_len == 33);
34964         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
34965         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34966         return ret_val;
34967 }
34968
34969 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
34970         LDKInitFeatures a_conv;
34971         a_conv.inner = (void*)(a & (~1));
34972         a_conv.is_owned = false;
34973         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34974         LDKInitFeatures b_conv;
34975         b_conv.inner = (void*)(b & (~1));
34976         b_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34978         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34979         return ret_val;
34980 }
34981
34982 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
34983         LDKNodeFeatures a_conv;
34984         a_conv.inner = (void*)(a & (~1));
34985         a_conv.is_owned = false;
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34987         LDKNodeFeatures b_conv;
34988         b_conv.inner = (void*)(b & (~1));
34989         b_conv.is_owned = false;
34990         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34991         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34992         return ret_val;
34993 }
34994
34995 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
34996         LDKChannelFeatures a_conv;
34997         a_conv.inner = (void*)(a & (~1));
34998         a_conv.is_owned = false;
34999         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35000         LDKChannelFeatures b_conv;
35001         b_conv.inner = (void*)(b & (~1));
35002         b_conv.is_owned = false;
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35004         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
35005         return ret_val;
35006 }
35007
35008 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
35009         LDKInvoiceFeatures a_conv;
35010         a_conv.inner = (void*)(a & (~1));
35011         a_conv.is_owned = false;
35012         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35013         LDKInvoiceFeatures b_conv;
35014         b_conv.inner = (void*)(b & (~1));
35015         b_conv.is_owned = false;
35016         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35017         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
35018         return ret_val;
35019 }
35020
35021 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
35022         LDKChannelTypeFeatures a_conv;
35023         a_conv.inner = (void*)(a & (~1));
35024         a_conv.is_owned = false;
35025         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35026         LDKChannelTypeFeatures b_conv;
35027         b_conv.inner = (void*)(b & (~1));
35028         b_conv.is_owned = false;
35029         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35030         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
35031         return ret_val;
35032 }
35033
35034 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
35035         LDKInitFeatures ret_var = InitFeatures_clone(arg);
35036 uint32_t ret_ref = 0;
35037 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35038 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35039 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35040 ret_ref = (uintptr_t)ret_var.inner;
35041 if (ret_var.is_owned) {
35042         ret_ref |= 1;
35043 }
35044         return ret_ref;
35045 }
35046 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
35047         LDKInitFeatures arg_conv;
35048         arg_conv.inner = (void*)(arg & (~1));
35049         arg_conv.is_owned = false;
35050         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35051         uint32_t ret_val = InitFeatures_clone_ptr(&arg_conv);
35052         return ret_val;
35053 }
35054
35055 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
35056         LDKInitFeatures orig_conv;
35057         orig_conv.inner = (void*)(orig & (~1));
35058         orig_conv.is_owned = false;
35059         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35060         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
35061         uint32_t ret_ref = 0;
35062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35065         ret_ref = (uintptr_t)ret_var.inner;
35066         if (ret_var.is_owned) {
35067                 ret_ref |= 1;
35068         }
35069         return ret_ref;
35070 }
35071
35072 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
35073         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
35074 uint32_t ret_ref = 0;
35075 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35076 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35077 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35078 ret_ref = (uintptr_t)ret_var.inner;
35079 if (ret_var.is_owned) {
35080         ret_ref |= 1;
35081 }
35082         return ret_ref;
35083 }
35084 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
35085         LDKNodeFeatures arg_conv;
35086         arg_conv.inner = (void*)(arg & (~1));
35087         arg_conv.is_owned = false;
35088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35089         uint32_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
35090         return ret_val;
35091 }
35092
35093 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
35094         LDKNodeFeatures orig_conv;
35095         orig_conv.inner = (void*)(orig & (~1));
35096         orig_conv.is_owned = false;
35097         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35098         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
35099         uint32_t ret_ref = 0;
35100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35103         ret_ref = (uintptr_t)ret_var.inner;
35104         if (ret_var.is_owned) {
35105                 ret_ref |= 1;
35106         }
35107         return ret_ref;
35108 }
35109
35110 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
35111         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
35112 uint32_t ret_ref = 0;
35113 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35114 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35115 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35116 ret_ref = (uintptr_t)ret_var.inner;
35117 if (ret_var.is_owned) {
35118         ret_ref |= 1;
35119 }
35120         return ret_ref;
35121 }
35122 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
35123         LDKChannelFeatures arg_conv;
35124         arg_conv.inner = (void*)(arg & (~1));
35125         arg_conv.is_owned = false;
35126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35127         uint32_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
35128         return ret_val;
35129 }
35130
35131 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
35132         LDKChannelFeatures orig_conv;
35133         orig_conv.inner = (void*)(orig & (~1));
35134         orig_conv.is_owned = false;
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35136         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
35137         uint32_t ret_ref = 0;
35138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35141         ret_ref = (uintptr_t)ret_var.inner;
35142         if (ret_var.is_owned) {
35143                 ret_ref |= 1;
35144         }
35145         return ret_ref;
35146 }
35147
35148 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
35149         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
35150 uint32_t ret_ref = 0;
35151 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35152 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35153 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35154 ret_ref = (uintptr_t)ret_var.inner;
35155 if (ret_var.is_owned) {
35156         ret_ref |= 1;
35157 }
35158         return ret_ref;
35159 }
35160 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
35161         LDKInvoiceFeatures arg_conv;
35162         arg_conv.inner = (void*)(arg & (~1));
35163         arg_conv.is_owned = false;
35164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35165         uint32_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
35166         return ret_val;
35167 }
35168
35169 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
35170         LDKInvoiceFeatures orig_conv;
35171         orig_conv.inner = (void*)(orig & (~1));
35172         orig_conv.is_owned = false;
35173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35174         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
35175         uint32_t ret_ref = 0;
35176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35179         ret_ref = (uintptr_t)ret_var.inner;
35180         if (ret_var.is_owned) {
35181                 ret_ref |= 1;
35182         }
35183         return ret_ref;
35184 }
35185
35186 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
35187         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
35188 uint32_t ret_ref = 0;
35189 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35190 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35191 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35192 ret_ref = (uintptr_t)ret_var.inner;
35193 if (ret_var.is_owned) {
35194         ret_ref |= 1;
35195 }
35196         return ret_ref;
35197 }
35198 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
35199         LDKChannelTypeFeatures arg_conv;
35200         arg_conv.inner = (void*)(arg & (~1));
35201         arg_conv.is_owned = false;
35202         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35203         uint32_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
35204         return ret_val;
35205 }
35206
35207 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
35208         LDKChannelTypeFeatures orig_conv;
35209         orig_conv.inner = (void*)(orig & (~1));
35210         orig_conv.is_owned = false;
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35212         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
35213         uint32_t ret_ref = 0;
35214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35217         ret_ref = (uintptr_t)ret_var.inner;
35218         if (ret_var.is_owned) {
35219                 ret_ref |= 1;
35220         }
35221         return ret_ref;
35222 }
35223
35224 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
35225         LDKInitFeatures this_obj_conv;
35226         this_obj_conv.inner = (void*)(this_obj & (~1));
35227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35229         InitFeatures_free(this_obj_conv);
35230 }
35231
35232 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
35233         LDKNodeFeatures this_obj_conv;
35234         this_obj_conv.inner = (void*)(this_obj & (~1));
35235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35237         NodeFeatures_free(this_obj_conv);
35238 }
35239
35240 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
35241         LDKChannelFeatures this_obj_conv;
35242         this_obj_conv.inner = (void*)(this_obj & (~1));
35243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35245         ChannelFeatures_free(this_obj_conv);
35246 }
35247
35248 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
35249         LDKInvoiceFeatures this_obj_conv;
35250         this_obj_conv.inner = (void*)(this_obj & (~1));
35251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35253         InvoiceFeatures_free(this_obj_conv);
35254 }
35255
35256 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
35257         LDKChannelTypeFeatures this_obj_conv;
35258         this_obj_conv.inner = (void*)(this_obj & (~1));
35259         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35261         ChannelTypeFeatures_free(this_obj_conv);
35262 }
35263
35264 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
35265         LDKInitFeatures ret_var = InitFeatures_empty();
35266         uint32_t ret_ref = 0;
35267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35270         ret_ref = (uintptr_t)ret_var.inner;
35271         if (ret_var.is_owned) {
35272                 ret_ref |= 1;
35273         }
35274         return ret_ref;
35275 }
35276
35277 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
35278         LDKInitFeatures ret_var = InitFeatures_known();
35279         uint32_t ret_ref = 0;
35280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35283         ret_ref = (uintptr_t)ret_var.inner;
35284         if (ret_var.is_owned) {
35285                 ret_ref |= 1;
35286         }
35287         return ret_ref;
35288 }
35289
35290 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
35291         LDKInitFeatures this_arg_conv;
35292         this_arg_conv.inner = (void*)(this_arg & (~1));
35293         this_arg_conv.is_owned = false;
35294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35295         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
35296         return ret_val;
35297 }
35298
35299 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
35300         LDKNodeFeatures ret_var = NodeFeatures_empty();
35301         uint32_t ret_ref = 0;
35302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35305         ret_ref = (uintptr_t)ret_var.inner;
35306         if (ret_var.is_owned) {
35307                 ret_ref |= 1;
35308         }
35309         return ret_ref;
35310 }
35311
35312 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
35313         LDKNodeFeatures ret_var = NodeFeatures_known();
35314         uint32_t ret_ref = 0;
35315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35318         ret_ref = (uintptr_t)ret_var.inner;
35319         if (ret_var.is_owned) {
35320                 ret_ref |= 1;
35321         }
35322         return ret_ref;
35323 }
35324
35325 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
35326         LDKNodeFeatures this_arg_conv;
35327         this_arg_conv.inner = (void*)(this_arg & (~1));
35328         this_arg_conv.is_owned = false;
35329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35330         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
35331         return ret_val;
35332 }
35333
35334 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
35335         LDKChannelFeatures ret_var = ChannelFeatures_empty();
35336         uint32_t ret_ref = 0;
35337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35340         ret_ref = (uintptr_t)ret_var.inner;
35341         if (ret_var.is_owned) {
35342                 ret_ref |= 1;
35343         }
35344         return ret_ref;
35345 }
35346
35347 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
35348         LDKChannelFeatures ret_var = ChannelFeatures_known();
35349         uint32_t ret_ref = 0;
35350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35353         ret_ref = (uintptr_t)ret_var.inner;
35354         if (ret_var.is_owned) {
35355                 ret_ref |= 1;
35356         }
35357         return ret_ref;
35358 }
35359
35360 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
35361         LDKChannelFeatures this_arg_conv;
35362         this_arg_conv.inner = (void*)(this_arg & (~1));
35363         this_arg_conv.is_owned = false;
35364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35365         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
35366         return ret_val;
35367 }
35368
35369 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
35370         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
35371         uint32_t ret_ref = 0;
35372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35375         ret_ref = (uintptr_t)ret_var.inner;
35376         if (ret_var.is_owned) {
35377                 ret_ref |= 1;
35378         }
35379         return ret_ref;
35380 }
35381
35382 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
35383         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
35384         uint32_t ret_ref = 0;
35385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35388         ret_ref = (uintptr_t)ret_var.inner;
35389         if (ret_var.is_owned) {
35390                 ret_ref |= 1;
35391         }
35392         return ret_ref;
35393 }
35394
35395 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
35396         LDKInvoiceFeatures this_arg_conv;
35397         this_arg_conv.inner = (void*)(this_arg & (~1));
35398         this_arg_conv.is_owned = false;
35399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35400         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
35401         return ret_val;
35402 }
35403
35404 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
35405         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
35406         uint32_t ret_ref = 0;
35407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35410         ret_ref = (uintptr_t)ret_var.inner;
35411         if (ret_var.is_owned) {
35412                 ret_ref |= 1;
35413         }
35414         return ret_ref;
35415 }
35416
35417 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
35418         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
35419         uint32_t ret_ref = 0;
35420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35423         ret_ref = (uintptr_t)ret_var.inner;
35424         if (ret_var.is_owned) {
35425                 ret_ref |= 1;
35426         }
35427         return ret_ref;
35428 }
35429
35430 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
35431         LDKChannelTypeFeatures this_arg_conv;
35432         this_arg_conv.inner = (void*)(this_arg & (~1));
35433         this_arg_conv.is_owned = false;
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35435         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
35436         return ret_val;
35437 }
35438
35439 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
35440         LDKInitFeatures obj_conv;
35441         obj_conv.inner = (void*)(obj & (~1));
35442         obj_conv.is_owned = false;
35443         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35444         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
35445         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35446         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35447         CVec_u8Z_free(ret_var);
35448         return ret_arr;
35449 }
35450
35451 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
35452         LDKu8slice ser_ref;
35453         ser_ref.datalen = ser->arr_len;
35454         ser_ref.data = ser->elems /* XXX ser leaks */;
35455         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
35456         *ret_conv = InitFeatures_read(ser_ref);
35457         return (uint32_t)ret_conv;
35458 }
35459
35460 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
35461         LDKChannelFeatures obj_conv;
35462         obj_conv.inner = (void*)(obj & (~1));
35463         obj_conv.is_owned = false;
35464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35465         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35466         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35467         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35468         CVec_u8Z_free(ret_var);
35469         return ret_arr;
35470 }
35471
35472 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
35473         LDKu8slice ser_ref;
35474         ser_ref.datalen = ser->arr_len;
35475         ser_ref.data = ser->elems /* XXX ser leaks */;
35476         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35477         *ret_conv = ChannelFeatures_read(ser_ref);
35478         return (uint32_t)ret_conv;
35479 }
35480
35481 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
35482         LDKNodeFeatures obj_conv;
35483         obj_conv.inner = (void*)(obj & (~1));
35484         obj_conv.is_owned = false;
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35486         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35487         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35488         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35489         CVec_u8Z_free(ret_var);
35490         return ret_arr;
35491 }
35492
35493 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
35494         LDKu8slice ser_ref;
35495         ser_ref.datalen = ser->arr_len;
35496         ser_ref.data = ser->elems /* XXX ser leaks */;
35497         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35498         *ret_conv = NodeFeatures_read(ser_ref);
35499         return (uint32_t)ret_conv;
35500 }
35501
35502 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
35503         LDKInvoiceFeatures obj_conv;
35504         obj_conv.inner = (void*)(obj & (~1));
35505         obj_conv.is_owned = false;
35506         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35507         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
35508         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35509         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35510         CVec_u8Z_free(ret_var);
35511         return ret_arr;
35512 }
35513
35514 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
35515         LDKu8slice ser_ref;
35516         ser_ref.datalen = ser->arr_len;
35517         ser_ref.data = ser->elems /* XXX ser leaks */;
35518         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35519         *ret_conv = InvoiceFeatures_read(ser_ref);
35520         return (uint32_t)ret_conv;
35521 }
35522
35523 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
35524         LDKChannelTypeFeatures obj_conv;
35525         obj_conv.inner = (void*)(obj & (~1));
35526         obj_conv.is_owned = false;
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35528         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
35529         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35530         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35531         CVec_u8Z_free(ret_var);
35532         return ret_arr;
35533 }
35534
35535 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
35536         LDKu8slice ser_ref;
35537         ser_ref.datalen = ser->arr_len;
35538         ser_ref.data = ser->elems /* XXX ser leaks */;
35539         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35540         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35541         return (uint32_t)ret_conv;
35542 }
35543
35544 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
35545         LDKShutdownScript this_obj_conv;
35546         this_obj_conv.inner = (void*)(this_obj & (~1));
35547         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35549         ShutdownScript_free(this_obj_conv);
35550 }
35551
35552 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35553         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35554 uint32_t ret_ref = 0;
35555 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35556 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35557 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35558 ret_ref = (uintptr_t)ret_var.inner;
35559 if (ret_var.is_owned) {
35560         ret_ref |= 1;
35561 }
35562         return ret_ref;
35563 }
35564 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
35565         LDKShutdownScript arg_conv;
35566         arg_conv.inner = (void*)(arg & (~1));
35567         arg_conv.is_owned = false;
35568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35569         uint32_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
35570         return ret_val;
35571 }
35572
35573 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
35574         LDKShutdownScript orig_conv;
35575         orig_conv.inner = (void*)(orig & (~1));
35576         orig_conv.is_owned = false;
35577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35578         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35579         uint32_t ret_ref = 0;
35580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35583         ret_ref = (uintptr_t)ret_var.inner;
35584         if (ret_var.is_owned) {
35585                 ret_ref |= 1;
35586         }
35587         return ret_ref;
35588 }
35589
35590 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
35591         LDKInvalidShutdownScript this_obj_conv;
35592         this_obj_conv.inner = (void*)(this_obj & (~1));
35593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35595         InvalidShutdownScript_free(this_obj_conv);
35596 }
35597
35598 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
35599         LDKInvalidShutdownScript this_ptr_conv;
35600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35601         this_ptr_conv.is_owned = false;
35602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35603         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35604         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35605         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35606         return ret_arr;
35607 }
35608
35609 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35610         LDKInvalidShutdownScript this_ptr_conv;
35611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35612         this_ptr_conv.is_owned = false;
35613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35614         LDKCVec_u8Z val_ref;
35615         val_ref.datalen = val->arr_len;
35616         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35617         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35618         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35619 }
35620
35621 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35622         LDKCVec_u8Z script_arg_ref;
35623         script_arg_ref.datalen = script_arg->arr_len;
35624         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35625         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35626         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35627         uint32_t ret_ref = 0;
35628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35631         ret_ref = (uintptr_t)ret_var.inner;
35632         if (ret_var.is_owned) {
35633                 ret_ref |= 1;
35634         }
35635         return ret_ref;
35636 }
35637
35638 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35639         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35640 uint32_t ret_ref = 0;
35641 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35642 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35643 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35644 ret_ref = (uintptr_t)ret_var.inner;
35645 if (ret_var.is_owned) {
35646         ret_ref |= 1;
35647 }
35648         return ret_ref;
35649 }
35650 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35651         LDKInvalidShutdownScript arg_conv;
35652         arg_conv.inner = (void*)(arg & (~1));
35653         arg_conv.is_owned = false;
35654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35655         uint32_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35656         return ret_val;
35657 }
35658
35659 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35660         LDKInvalidShutdownScript orig_conv;
35661         orig_conv.inner = (void*)(orig & (~1));
35662         orig_conv.is_owned = false;
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35664         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35665         uint32_t ret_ref = 0;
35666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35669         ret_ref = (uintptr_t)ret_var.inner;
35670         if (ret_var.is_owned) {
35671                 ret_ref |= 1;
35672         }
35673         return ret_ref;
35674 }
35675
35676 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35677         LDKShutdownScript obj_conv;
35678         obj_conv.inner = (void*)(obj & (~1));
35679         obj_conv.is_owned = false;
35680         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35681         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35682         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35683         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35684         CVec_u8Z_free(ret_var);
35685         return ret_arr;
35686 }
35687
35688 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35689         LDKu8slice ser_ref;
35690         ser_ref.datalen = ser->arr_len;
35691         ser_ref.data = ser->elems /* XXX ser leaks */;
35692         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35693         *ret_conv = ShutdownScript_read(ser_ref);
35694         return (uint32_t)ret_conv;
35695 }
35696
35697 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35698         unsigned char pubkey_hash_arr[20];
35699         CHECK(pubkey_hash->arr_len == 20);
35700         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35701         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35702         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35703         uint32_t ret_ref = 0;
35704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35707         ret_ref = (uintptr_t)ret_var.inner;
35708         if (ret_var.is_owned) {
35709                 ret_ref |= 1;
35710         }
35711         return ret_ref;
35712 }
35713
35714 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35715         unsigned char script_hash_arr[32];
35716         CHECK(script_hash->arr_len == 32);
35717         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35718         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35719         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35720         uint32_t ret_ref = 0;
35721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35724         ret_ref = (uintptr_t)ret_var.inner;
35725         if (ret_var.is_owned) {
35726                 ret_ref |= 1;
35727         }
35728         return ret_ref;
35729 }
35730
35731 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35732         LDKu8slice program_ref;
35733         program_ref.datalen = program->arr_len;
35734         program_ref.data = program->elems /* XXX program leaks */;
35735         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35736         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35737         return (uint32_t)ret_conv;
35738 }
35739
35740 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35741         LDKShutdownScript this_arg_conv;
35742         this_arg_conv.inner = (void*)(this_arg & (~1));
35743         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35745         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35746         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35747         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35748         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35749         CVec_u8Z_free(ret_var);
35750         return ret_arr;
35751 }
35752
35753 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35754         LDKShutdownScript this_arg_conv;
35755         this_arg_conv.inner = (void*)(this_arg & (~1));
35756         this_arg_conv.is_owned = false;
35757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35758         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35759         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35760         return ret_arr;
35761 }
35762
35763 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35764         LDKShutdownScript this_arg_conv;
35765         this_arg_conv.inner = (void*)(this_arg & (~1));
35766         this_arg_conv.is_owned = false;
35767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35768         LDKInitFeatures features_conv;
35769         features_conv.inner = (void*)(features & (~1));
35770         features_conv.is_owned = false;
35771         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35772         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35773         return ret_val;
35774 }
35775
35776 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35777         if ((this_ptr & 1) != 0) return;
35778         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35779         CHECK_ACCESS(this_ptr_ptr);
35780         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35781         FREE((void*)this_ptr);
35782         CustomMessageReader_free(this_ptr_conv);
35783 }
35784
35785 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35786         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35787         *ret_ret = Type_clone(arg);
35788         return (uint32_t)ret_ret;
35789 }
35790 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35791         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35792         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35793         LDKType* arg_conv = (LDKType*)arg_ptr;
35794         uint32_t ret_val = Type_clone_ptr(arg_conv);
35795         return ret_val;
35796 }
35797
35798 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35799         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35800         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35801         LDKType* orig_conv = (LDKType*)orig_ptr;
35802         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35803         *ret_ret = Type_clone(orig_conv);
35804         return (uint32_t)ret_ret;
35805 }
35806
35807 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35808         if ((this_ptr & 1) != 0) return;
35809         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35810         CHECK_ACCESS(this_ptr_ptr);
35811         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35812         FREE((void*)this_ptr);
35813         Type_free(this_ptr_conv);
35814 }
35815
35816 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35817         LDKNodeId this_obj_conv;
35818         this_obj_conv.inner = (void*)(this_obj & (~1));
35819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35821         NodeId_free(this_obj_conv);
35822 }
35823
35824 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35825         LDKNodeId ret_var = NodeId_clone(arg);
35826 uint32_t ret_ref = 0;
35827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35830 ret_ref = (uintptr_t)ret_var.inner;
35831 if (ret_var.is_owned) {
35832         ret_ref |= 1;
35833 }
35834         return ret_ref;
35835 }
35836 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35837         LDKNodeId arg_conv;
35838         arg_conv.inner = (void*)(arg & (~1));
35839         arg_conv.is_owned = false;
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35841         uint32_t ret_val = NodeId_clone_ptr(&arg_conv);
35842         return ret_val;
35843 }
35844
35845 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35846         LDKNodeId orig_conv;
35847         orig_conv.inner = (void*)(orig & (~1));
35848         orig_conv.is_owned = false;
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35850         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35851         uint32_t ret_ref = 0;
35852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35855         ret_ref = (uintptr_t)ret_var.inner;
35856         if (ret_var.is_owned) {
35857                 ret_ref |= 1;
35858         }
35859         return ret_ref;
35860 }
35861
35862 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35863         LDKPublicKey pubkey_ref;
35864         CHECK(pubkey->arr_len == 33);
35865         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35866         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35867         uint32_t ret_ref = 0;
35868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35871         ret_ref = (uintptr_t)ret_var.inner;
35872         if (ret_var.is_owned) {
35873                 ret_ref |= 1;
35874         }
35875         return ret_ref;
35876 }
35877
35878 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35879         LDKNodeId this_arg_conv;
35880         this_arg_conv.inner = (void*)(this_arg & (~1));
35881         this_arg_conv.is_owned = false;
35882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35883         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35884         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35885         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35886         return ret_arr;
35887 }
35888
35889 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35890         LDKNodeId o_conv;
35891         o_conv.inner = (void*)(o & (~1));
35892         o_conv.is_owned = false;
35893         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35894         int64_t ret_val = NodeId_hash(&o_conv);
35895         return ret_val;
35896 }
35897
35898 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35899         LDKNodeId obj_conv;
35900         obj_conv.inner = (void*)(obj & (~1));
35901         obj_conv.is_owned = false;
35902         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35903         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35904         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35905         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35906         CVec_u8Z_free(ret_var);
35907         return ret_arr;
35908 }
35909
35910 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35911         LDKu8slice ser_ref;
35912         ser_ref.datalen = ser->arr_len;
35913         ser_ref.data = ser->elems /* XXX ser leaks */;
35914         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35915         *ret_conv = NodeId_read(ser_ref);
35916         return (uint32_t)ret_conv;
35917 }
35918
35919 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35920         LDKNetworkGraph this_obj_conv;
35921         this_obj_conv.inner = (void*)(this_obj & (~1));
35922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35924         NetworkGraph_free(this_obj_conv);
35925 }
35926
35927 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35928         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35929 uint32_t ret_ref = 0;
35930 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35931 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35932 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35933 ret_ref = (uintptr_t)ret_var.inner;
35934 if (ret_var.is_owned) {
35935         ret_ref |= 1;
35936 }
35937         return ret_ref;
35938 }
35939 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35940         LDKNetworkGraph arg_conv;
35941         arg_conv.inner = (void*)(arg & (~1));
35942         arg_conv.is_owned = false;
35943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35944         uint32_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35945         return ret_val;
35946 }
35947
35948 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
35949         LDKNetworkGraph orig_conv;
35950         orig_conv.inner = (void*)(orig & (~1));
35951         orig_conv.is_owned = false;
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35953         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35954         uint32_t ret_ref = 0;
35955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35958         ret_ref = (uintptr_t)ret_var.inner;
35959         if (ret_var.is_owned) {
35960                 ret_ref |= 1;
35961         }
35962         return ret_ref;
35963 }
35964
35965 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
35966         LDKReadOnlyNetworkGraph this_obj_conv;
35967         this_obj_conv.inner = (void*)(this_obj & (~1));
35968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35970         ReadOnlyNetworkGraph_free(this_obj_conv);
35971 }
35972
35973 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
35974         if ((this_ptr & 1) != 0) return;
35975         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35976         CHECK_ACCESS(this_ptr_ptr);
35977         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35978         FREE((void*)this_ptr);
35979         NetworkUpdate_free(this_ptr_conv);
35980 }
35981
35982 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35983         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35984         *ret_copy = NetworkUpdate_clone(arg);
35985 uint32_t ret_ref = (uintptr_t)ret_copy;
35986         return ret_ref;
35987 }
35988 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
35989         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35990         uint32_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35991         return ret_val;
35992 }
35993
35994 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
35995         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35996         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35997         *ret_copy = NetworkUpdate_clone(orig_conv);
35998         uint32_t ret_ref = (uintptr_t)ret_copy;
35999         return ret_ref;
36000 }
36001
36002 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
36003         LDKChannelUpdate msg_conv;
36004         msg_conv.inner = (void*)(msg & (~1));
36005         msg_conv.is_owned = (msg & 1) || (msg == 0);
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36007         msg_conv = ChannelUpdate_clone(&msg_conv);
36008         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36009         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
36010         uint32_t ret_ref = (uintptr_t)ret_copy;
36011         return ret_ref;
36012 }
36013
36014 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
36015         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36016         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
36017         uint32_t ret_ref = (uintptr_t)ret_copy;
36018         return ret_ref;
36019 }
36020
36021 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
36022         LDKPublicKey node_id_ref;
36023         CHECK(node_id->arr_len == 33);
36024         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
36025         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36026         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
36027         uint32_t ret_ref = (uintptr_t)ret_copy;
36028         return ret_ref;
36029 }
36030
36031 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
36032         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
36033         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
36034         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36035         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36036         CVec_u8Z_free(ret_var);
36037         return ret_arr;
36038 }
36039
36040 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
36041         LDKu8slice ser_ref;
36042         ser_ref.datalen = ser->arr_len;
36043         ser_ref.data = ser->elems /* XXX ser leaks */;
36044         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
36045         *ret_conv = NetworkUpdate_read(ser_ref);
36046         return (uint32_t)ret_conv;
36047 }
36048
36049 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
36050         LDKNetGraphMsgHandler this_arg_conv;
36051         this_arg_conv.inner = (void*)(this_arg & (~1));
36052         this_arg_conv.is_owned = false;
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36054         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
36055         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
36056         return (uint32_t)ret_ret;
36057 }
36058
36059 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
36060         LDKNetGraphMsgHandler this_obj_conv;
36061         this_obj_conv.inner = (void*)(this_obj & (~1));
36062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36064         NetGraphMsgHandler_free(this_obj_conv);
36065 }
36066
36067 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
36068         LDKNetworkGraph network_graph_conv;
36069         network_graph_conv.inner = (void*)(network_graph & (~1));
36070         network_graph_conv.is_owned = false;
36071         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
36072         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36073         CHECK_ACCESS(chain_access_ptr);
36074         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36075         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36076         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36077                 // Manually implement clone for Java trait instances
36078                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36079                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36080                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36081                 }
36082         }
36083         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36084         CHECK_ACCESS(logger_ptr);
36085         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36086         if (logger_conv.free == LDKLogger_JCalls_free) {
36087                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36088                 LDKLogger_JCalls_cloned(&logger_conv);
36089         }
36090         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
36091         uint32_t ret_ref = 0;
36092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36095         ret_ref = (uintptr_t)ret_var.inner;
36096         if (ret_var.is_owned) {
36097                 ret_ref |= 1;
36098         }
36099         return ret_ref;
36100 }
36101
36102 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
36103         LDKNetGraphMsgHandler this_arg_conv;
36104         this_arg_conv.inner = (void*)(this_arg & (~1));
36105         this_arg_conv.is_owned = false;
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36107         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36108         CHECK_ACCESS(chain_access_ptr);
36109         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36110         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36111         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36112                 // Manually implement clone for Java trait instances
36113                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36114                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36115                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36116                 }
36117         }
36118         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
36119 }
36120
36121 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
36122         LDKNetGraphMsgHandler this_arg_conv;
36123         this_arg_conv.inner = (void*)(this_arg & (~1));
36124         this_arg_conv.is_owned = false;
36125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36126         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36127         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
36128         return (uint32_t)ret_ret;
36129 }
36130
36131 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
36132         LDKNetGraphMsgHandler this_arg_conv;
36133         this_arg_conv.inner = (void*)(this_arg & (~1));
36134         this_arg_conv.is_owned = false;
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36136         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36137         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
36138         return (uint32_t)ret_ret;
36139 }
36140
36141 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
36142         LDKChannelUpdateInfo this_obj_conv;
36143         this_obj_conv.inner = (void*)(this_obj & (~1));
36144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36146         ChannelUpdateInfo_free(this_obj_conv);
36147 }
36148
36149 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
36150         LDKChannelUpdateInfo this_ptr_conv;
36151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36152         this_ptr_conv.is_owned = false;
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36154         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
36155         return ret_val;
36156 }
36157
36158 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36159         LDKChannelUpdateInfo this_ptr_conv;
36160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36161         this_ptr_conv.is_owned = false;
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36163         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
36164 }
36165
36166 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
36167         LDKChannelUpdateInfo this_ptr_conv;
36168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36169         this_ptr_conv.is_owned = false;
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36171         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
36172         return ret_val;
36173 }
36174
36175 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
36176         LDKChannelUpdateInfo this_ptr_conv;
36177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36178         this_ptr_conv.is_owned = false;
36179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36180         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
36181 }
36182
36183 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
36184         LDKChannelUpdateInfo this_ptr_conv;
36185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36186         this_ptr_conv.is_owned = false;
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36188         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
36189         return ret_val;
36190 }
36191
36192 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
36193         LDKChannelUpdateInfo this_ptr_conv;
36194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36195         this_ptr_conv.is_owned = false;
36196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36197         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
36198 }
36199
36200 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
36201         LDKChannelUpdateInfo this_ptr_conv;
36202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36203         this_ptr_conv.is_owned = false;
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36205         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
36206         return ret_val;
36207 }
36208
36209 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
36210         LDKChannelUpdateInfo this_ptr_conv;
36211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36212         this_ptr_conv.is_owned = false;
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36214         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
36215 }
36216
36217 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
36218         LDKChannelUpdateInfo this_ptr_conv;
36219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36220         this_ptr_conv.is_owned = false;
36221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36222         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36223         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
36224         uint32_t ret_ref = (uintptr_t)ret_copy;
36225         return ret_ref;
36226 }
36227
36228 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
36229         LDKChannelUpdateInfo this_ptr_conv;
36230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36231         this_ptr_conv.is_owned = false;
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36233         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36234         CHECK_ACCESS(val_ptr);
36235         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36236         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36237         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
36238 }
36239
36240 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
36241         LDKChannelUpdateInfo this_ptr_conv;
36242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36243         this_ptr_conv.is_owned = false;
36244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36245         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
36246         uint32_t ret_ref = 0;
36247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36250         ret_ref = (uintptr_t)ret_var.inner;
36251         if (ret_var.is_owned) {
36252                 ret_ref |= 1;
36253         }
36254         return ret_ref;
36255 }
36256
36257 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
36258         LDKChannelUpdateInfo this_ptr_conv;
36259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36260         this_ptr_conv.is_owned = false;
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36262         LDKRoutingFees val_conv;
36263         val_conv.inner = (void*)(val & (~1));
36264         val_conv.is_owned = (val & 1) || (val == 0);
36265         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36266         val_conv = RoutingFees_clone(&val_conv);
36267         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
36268 }
36269
36270 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
36271         LDKChannelUpdateInfo this_ptr_conv;
36272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36273         this_ptr_conv.is_owned = false;
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36275         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
36276         uint32_t ret_ref = 0;
36277         if ((uintptr_t)ret_var.inner > 4096) {
36278                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36279                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36281                 ret_ref = (uintptr_t)ret_var.inner;
36282                 if (ret_var.is_owned) {
36283                         ret_ref |= 1;
36284                 }
36285         }
36286         return ret_ref;
36287 }
36288
36289 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
36290         LDKChannelUpdateInfo this_ptr_conv;
36291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36292         this_ptr_conv.is_owned = false;
36293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36294         LDKChannelUpdate val_conv;
36295         val_conv.inner = (void*)(val & (~1));
36296         val_conv.is_owned = (val & 1) || (val == 0);
36297         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36298         val_conv = ChannelUpdate_clone(&val_conv);
36299         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
36300 }
36301
36302 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_new"))) TS_ChannelUpdateInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
36303         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
36304         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
36305         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
36306         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
36307         LDKRoutingFees fees_arg_conv;
36308         fees_arg_conv.inner = (void*)(fees_arg & (~1));
36309         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
36310         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
36311         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
36312         LDKChannelUpdate last_update_message_arg_conv;
36313         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
36314         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
36315         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
36316         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
36317         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
36318         uint32_t ret_ref = 0;
36319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36322         ret_ref = (uintptr_t)ret_var.inner;
36323         if (ret_var.is_owned) {
36324                 ret_ref |= 1;
36325         }
36326         return ret_ref;
36327 }
36328
36329 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
36330         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
36331 uint32_t ret_ref = 0;
36332 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36333 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36335 ret_ref = (uintptr_t)ret_var.inner;
36336 if (ret_var.is_owned) {
36337         ret_ref |= 1;
36338 }
36339         return ret_ref;
36340 }
36341 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
36342         LDKChannelUpdateInfo arg_conv;
36343         arg_conv.inner = (void*)(arg & (~1));
36344         arg_conv.is_owned = false;
36345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36346         uint32_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
36347         return ret_val;
36348 }
36349
36350 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
36351         LDKChannelUpdateInfo orig_conv;
36352         orig_conv.inner = (void*)(orig & (~1));
36353         orig_conv.is_owned = false;
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36355         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
36356         uint32_t ret_ref = 0;
36357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36360         ret_ref = (uintptr_t)ret_var.inner;
36361         if (ret_var.is_owned) {
36362                 ret_ref |= 1;
36363         }
36364         return ret_ref;
36365 }
36366
36367 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
36368         LDKChannelUpdateInfo obj_conv;
36369         obj_conv.inner = (void*)(obj & (~1));
36370         obj_conv.is_owned = false;
36371         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36372         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
36373         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36374         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36375         CVec_u8Z_free(ret_var);
36376         return ret_arr;
36377 }
36378
36379 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
36380         LDKu8slice ser_ref;
36381         ser_ref.datalen = ser->arr_len;
36382         ser_ref.data = ser->elems /* XXX ser leaks */;
36383         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
36384         *ret_conv = ChannelUpdateInfo_read(ser_ref);
36385         return (uint32_t)ret_conv;
36386 }
36387
36388 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
36389         LDKChannelInfo this_obj_conv;
36390         this_obj_conv.inner = (void*)(this_obj & (~1));
36391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36393         ChannelInfo_free(this_obj_conv);
36394 }
36395
36396 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
36397         LDKChannelInfo this_ptr_conv;
36398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36399         this_ptr_conv.is_owned = false;
36400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36401         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
36402         uint32_t ret_ref = 0;
36403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36406         ret_ref = (uintptr_t)ret_var.inner;
36407         if (ret_var.is_owned) {
36408                 ret_ref |= 1;
36409         }
36410         return ret_ref;
36411 }
36412
36413 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
36414         LDKChannelInfo this_ptr_conv;
36415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36416         this_ptr_conv.is_owned = false;
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36418         LDKChannelFeatures val_conv;
36419         val_conv.inner = (void*)(val & (~1));
36420         val_conv.is_owned = (val & 1) || (val == 0);
36421         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36422         val_conv = ChannelFeatures_clone(&val_conv);
36423         ChannelInfo_set_features(&this_ptr_conv, val_conv);
36424 }
36425
36426 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
36427         LDKChannelInfo this_ptr_conv;
36428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36429         this_ptr_conv.is_owned = false;
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36431         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
36432         uint32_t ret_ref = 0;
36433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36436         ret_ref = (uintptr_t)ret_var.inner;
36437         if (ret_var.is_owned) {
36438                 ret_ref |= 1;
36439         }
36440         return ret_ref;
36441 }
36442
36443 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
36444         LDKChannelInfo this_ptr_conv;
36445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36446         this_ptr_conv.is_owned = false;
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36448         LDKNodeId val_conv;
36449         val_conv.inner = (void*)(val & (~1));
36450         val_conv.is_owned = (val & 1) || (val == 0);
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36452         val_conv = NodeId_clone(&val_conv);
36453         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
36454 }
36455
36456 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
36457         LDKChannelInfo this_ptr_conv;
36458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36459         this_ptr_conv.is_owned = false;
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36461         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
36462         uint32_t ret_ref = 0;
36463         if ((uintptr_t)ret_var.inner > 4096) {
36464                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36465                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36467                 ret_ref = (uintptr_t)ret_var.inner;
36468                 if (ret_var.is_owned) {
36469                         ret_ref |= 1;
36470                 }
36471         }
36472         return ret_ref;
36473 }
36474
36475 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
36476         LDKChannelInfo this_ptr_conv;
36477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36478         this_ptr_conv.is_owned = false;
36479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36480         LDKChannelUpdateInfo val_conv;
36481         val_conv.inner = (void*)(val & (~1));
36482         val_conv.is_owned = (val & 1) || (val == 0);
36483         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36484         val_conv = ChannelUpdateInfo_clone(&val_conv);
36485         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36486 }
36487
36488 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
36489         LDKChannelInfo this_ptr_conv;
36490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36491         this_ptr_conv.is_owned = false;
36492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36493         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36494         uint32_t ret_ref = 0;
36495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36498         ret_ref = (uintptr_t)ret_var.inner;
36499         if (ret_var.is_owned) {
36500                 ret_ref |= 1;
36501         }
36502         return ret_ref;
36503 }
36504
36505 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
36506         LDKChannelInfo this_ptr_conv;
36507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36508         this_ptr_conv.is_owned = false;
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36510         LDKNodeId val_conv;
36511         val_conv.inner = (void*)(val & (~1));
36512         val_conv.is_owned = (val & 1) || (val == 0);
36513         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36514         val_conv = NodeId_clone(&val_conv);
36515         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36516 }
36517
36518 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
36519         LDKChannelInfo this_ptr_conv;
36520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36521         this_ptr_conv.is_owned = false;
36522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36523         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36524         uint32_t ret_ref = 0;
36525         if ((uintptr_t)ret_var.inner > 4096) {
36526                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36527                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36529                 ret_ref = (uintptr_t)ret_var.inner;
36530                 if (ret_var.is_owned) {
36531                         ret_ref |= 1;
36532                 }
36533         }
36534         return ret_ref;
36535 }
36536
36537 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
36538         LDKChannelInfo this_ptr_conv;
36539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36540         this_ptr_conv.is_owned = false;
36541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36542         LDKChannelUpdateInfo val_conv;
36543         val_conv.inner = (void*)(val & (~1));
36544         val_conv.is_owned = (val & 1) || (val == 0);
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36546         val_conv = ChannelUpdateInfo_clone(&val_conv);
36547         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36548 }
36549
36550 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
36551         LDKChannelInfo this_ptr_conv;
36552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36553         this_ptr_conv.is_owned = false;
36554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36555         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36556         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36557         uint32_t ret_ref = (uintptr_t)ret_copy;
36558         return ret_ref;
36559 }
36560
36561 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
36562         LDKChannelInfo this_ptr_conv;
36563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36564         this_ptr_conv.is_owned = false;
36565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36566         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36567         CHECK_ACCESS(val_ptr);
36568         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36569         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36570         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36571 }
36572
36573 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
36574         LDKChannelInfo this_ptr_conv;
36575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36576         this_ptr_conv.is_owned = false;
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36578         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36579         uint32_t ret_ref = 0;
36580         if ((uintptr_t)ret_var.inner > 4096) {
36581                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36582                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36584                 ret_ref = (uintptr_t)ret_var.inner;
36585                 if (ret_var.is_owned) {
36586                         ret_ref |= 1;
36587                 }
36588         }
36589         return ret_ref;
36590 }
36591
36592 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36593         LDKChannelInfo this_ptr_conv;
36594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36595         this_ptr_conv.is_owned = false;
36596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36597         LDKChannelAnnouncement val_conv;
36598         val_conv.inner = (void*)(val & (~1));
36599         val_conv.is_owned = (val & 1) || (val == 0);
36600         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36601         val_conv = ChannelAnnouncement_clone(&val_conv);
36602         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36603 }
36604
36605 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36606         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36607 uint32_t ret_ref = 0;
36608 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36609 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36610 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36611 ret_ref = (uintptr_t)ret_var.inner;
36612 if (ret_var.is_owned) {
36613         ret_ref |= 1;
36614 }
36615         return ret_ref;
36616 }
36617 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36618         LDKChannelInfo arg_conv;
36619         arg_conv.inner = (void*)(arg & (~1));
36620         arg_conv.is_owned = false;
36621         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36622         uint32_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36623         return ret_val;
36624 }
36625
36626 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36627         LDKChannelInfo orig_conv;
36628         orig_conv.inner = (void*)(orig & (~1));
36629         orig_conv.is_owned = false;
36630         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36631         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36632         uint32_t ret_ref = 0;
36633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36636         ret_ref = (uintptr_t)ret_var.inner;
36637         if (ret_var.is_owned) {
36638                 ret_ref |= 1;
36639         }
36640         return ret_ref;
36641 }
36642
36643 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36644         LDKChannelInfo obj_conv;
36645         obj_conv.inner = (void*)(obj & (~1));
36646         obj_conv.is_owned = false;
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36648         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36649         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36650         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36651         CVec_u8Z_free(ret_var);
36652         return ret_arr;
36653 }
36654
36655 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36656         LDKu8slice ser_ref;
36657         ser_ref.datalen = ser->arr_len;
36658         ser_ref.data = ser->elems /* XXX ser leaks */;
36659         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36660         *ret_conv = ChannelInfo_read(ser_ref);
36661         return (uint32_t)ret_conv;
36662 }
36663
36664 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36665         LDKDirectedChannelInfo this_obj_conv;
36666         this_obj_conv.inner = (void*)(this_obj & (~1));
36667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36669         DirectedChannelInfo_free(this_obj_conv);
36670 }
36671
36672 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36673         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36674 uint32_t ret_ref = 0;
36675 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36676 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36677 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36678 ret_ref = (uintptr_t)ret_var.inner;
36679 if (ret_var.is_owned) {
36680         ret_ref |= 1;
36681 }
36682         return ret_ref;
36683 }
36684 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36685         LDKDirectedChannelInfo arg_conv;
36686         arg_conv.inner = (void*)(arg & (~1));
36687         arg_conv.is_owned = false;
36688         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36689         uint32_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
36690         return ret_val;
36691 }
36692
36693 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36694         LDKDirectedChannelInfo orig_conv;
36695         orig_conv.inner = (void*)(orig & (~1));
36696         orig_conv.is_owned = false;
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36698         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36699         uint32_t ret_ref = 0;
36700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36703         ret_ref = (uintptr_t)ret_var.inner;
36704         if (ret_var.is_owned) {
36705                 ret_ref |= 1;
36706         }
36707         return ret_ref;
36708 }
36709
36710 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36711         LDKDirectedChannelInfo this_arg_conv;
36712         this_arg_conv.inner = (void*)(this_arg & (~1));
36713         this_arg_conv.is_owned = false;
36714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36715         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36716         uint32_t ret_ref = 0;
36717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36720         ret_ref = (uintptr_t)ret_var.inner;
36721         if (ret_var.is_owned) {
36722                 ret_ref |= 1;
36723         }
36724         return ret_ref;
36725 }
36726
36727 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36728         LDKDirectedChannelInfo this_arg_conv;
36729         this_arg_conv.inner = (void*)(this_arg & (~1));
36730         this_arg_conv.is_owned = false;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36732         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36733         uint32_t ret_ref = 0;
36734         if ((uintptr_t)ret_var.inner > 4096) {
36735                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36736                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36738                 ret_ref = (uintptr_t)ret_var.inner;
36739                 if (ret_var.is_owned) {
36740                         ret_ref |= 1;
36741                 }
36742         }
36743         return ret_ref;
36744 }
36745
36746 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36747         LDKDirectedChannelInfo this_arg_conv;
36748         this_arg_conv.inner = (void*)(this_arg & (~1));
36749         this_arg_conv.is_owned = false;
36750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36751         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36752         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36753         uint32_t ret_ref = (uintptr_t)ret_copy;
36754         return ret_ref;
36755 }
36756
36757 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36758         if ((this_ptr & 1) != 0) return;
36759         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36760         CHECK_ACCESS(this_ptr_ptr);
36761         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36762         FREE((void*)this_ptr);
36763         EffectiveCapacity_free(this_ptr_conv);
36764 }
36765
36766 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36767         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36768         *ret_copy = EffectiveCapacity_clone(arg);
36769 uint32_t ret_ref = (uintptr_t)ret_copy;
36770         return ret_ref;
36771 }
36772 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36773         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36774         uint32_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
36775         return ret_val;
36776 }
36777
36778 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36779         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36780         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36781         *ret_copy = EffectiveCapacity_clone(orig_conv);
36782         uint32_t ret_ref = (uintptr_t)ret_copy;
36783         return ret_ref;
36784 }
36785
36786 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36787         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36788         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36789         uint32_t ret_ref = (uintptr_t)ret_copy;
36790         return ret_ref;
36791 }
36792
36793 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36794         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36795         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36796         uint32_t ret_ref = (uintptr_t)ret_copy;
36797         return ret_ref;
36798 }
36799
36800 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36801         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36802         *ret_copy = EffectiveCapacity_total(capacity_msat);
36803         uint32_t ret_ref = (uintptr_t)ret_copy;
36804         return ret_ref;
36805 }
36806
36807 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36808         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36809         *ret_copy = EffectiveCapacity_infinite();
36810         uint32_t ret_ref = (uintptr_t)ret_copy;
36811         return ret_ref;
36812 }
36813
36814 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36815         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36816         *ret_copy = EffectiveCapacity_unknown();
36817         uint32_t ret_ref = (uintptr_t)ret_copy;
36818         return ret_ref;
36819 }
36820
36821 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36822         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36823         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
36824         return ret_val;
36825 }
36826
36827 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36828         LDKRoutingFees this_obj_conv;
36829         this_obj_conv.inner = (void*)(this_obj & (~1));
36830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36832         RoutingFees_free(this_obj_conv);
36833 }
36834
36835 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36836         LDKRoutingFees this_ptr_conv;
36837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36838         this_ptr_conv.is_owned = false;
36839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36840         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36841         return ret_val;
36842 }
36843
36844 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36845         LDKRoutingFees this_ptr_conv;
36846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36847         this_ptr_conv.is_owned = false;
36848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36849         RoutingFees_set_base_msat(&this_ptr_conv, val);
36850 }
36851
36852 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36853         LDKRoutingFees this_ptr_conv;
36854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36855         this_ptr_conv.is_owned = false;
36856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36857         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36858         return ret_val;
36859 }
36860
36861 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36862         LDKRoutingFees this_ptr_conv;
36863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36864         this_ptr_conv.is_owned = false;
36865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36866         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36867 }
36868
36869 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36870         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36871         uint32_t ret_ref = 0;
36872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36875         ret_ref = (uintptr_t)ret_var.inner;
36876         if (ret_var.is_owned) {
36877                 ret_ref |= 1;
36878         }
36879         return ret_ref;
36880 }
36881
36882 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36883         LDKRoutingFees a_conv;
36884         a_conv.inner = (void*)(a & (~1));
36885         a_conv.is_owned = false;
36886         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36887         LDKRoutingFees b_conv;
36888         b_conv.inner = (void*)(b & (~1));
36889         b_conv.is_owned = false;
36890         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36891         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36892         return ret_val;
36893 }
36894
36895 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36896         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36897 uint32_t ret_ref = 0;
36898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36901 ret_ref = (uintptr_t)ret_var.inner;
36902 if (ret_var.is_owned) {
36903         ret_ref |= 1;
36904 }
36905         return ret_ref;
36906 }
36907 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36908         LDKRoutingFees arg_conv;
36909         arg_conv.inner = (void*)(arg & (~1));
36910         arg_conv.is_owned = false;
36911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36912         uint32_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36913         return ret_val;
36914 }
36915
36916 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36917         LDKRoutingFees orig_conv;
36918         orig_conv.inner = (void*)(orig & (~1));
36919         orig_conv.is_owned = false;
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36921         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36922         uint32_t ret_ref = 0;
36923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36926         ret_ref = (uintptr_t)ret_var.inner;
36927         if (ret_var.is_owned) {
36928                 ret_ref |= 1;
36929         }
36930         return ret_ref;
36931 }
36932
36933 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36934         LDKRoutingFees o_conv;
36935         o_conv.inner = (void*)(o & (~1));
36936         o_conv.is_owned = false;
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36938         int64_t ret_val = RoutingFees_hash(&o_conv);
36939         return ret_val;
36940 }
36941
36942 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
36943         LDKRoutingFees obj_conv;
36944         obj_conv.inner = (void*)(obj & (~1));
36945         obj_conv.is_owned = false;
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36947         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36948         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36949         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36950         CVec_u8Z_free(ret_var);
36951         return ret_arr;
36952 }
36953
36954 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
36955         LDKu8slice ser_ref;
36956         ser_ref.datalen = ser->arr_len;
36957         ser_ref.data = ser->elems /* XXX ser leaks */;
36958         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36959         *ret_conv = RoutingFees_read(ser_ref);
36960         return (uint32_t)ret_conv;
36961 }
36962
36963 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
36964         LDKNodeAnnouncementInfo this_obj_conv;
36965         this_obj_conv.inner = (void*)(this_obj & (~1));
36966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36968         NodeAnnouncementInfo_free(this_obj_conv);
36969 }
36970
36971 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
36972         LDKNodeAnnouncementInfo this_ptr_conv;
36973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36974         this_ptr_conv.is_owned = false;
36975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36976         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36977         uint32_t ret_ref = 0;
36978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36981         ret_ref = (uintptr_t)ret_var.inner;
36982         if (ret_var.is_owned) {
36983                 ret_ref |= 1;
36984         }
36985         return ret_ref;
36986 }
36987
36988 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
36989         LDKNodeAnnouncementInfo this_ptr_conv;
36990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36991         this_ptr_conv.is_owned = false;
36992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36993         LDKNodeFeatures val_conv;
36994         val_conv.inner = (void*)(val & (~1));
36995         val_conv.is_owned = (val & 1) || (val == 0);
36996         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36997         val_conv = NodeFeatures_clone(&val_conv);
36998         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36999 }
37000
37001 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
37002         LDKNodeAnnouncementInfo this_ptr_conv;
37003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37004         this_ptr_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37006         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
37007         return ret_val;
37008 }
37009
37010 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
37011         LDKNodeAnnouncementInfo this_ptr_conv;
37012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37013         this_ptr_conv.is_owned = false;
37014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37015         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
37016 }
37017
37018 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
37019         LDKNodeAnnouncementInfo this_ptr_conv;
37020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37021         this_ptr_conv.is_owned = false;
37022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37023         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
37024         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
37025         return ret_arr;
37026 }
37027
37028 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
37029         LDKNodeAnnouncementInfo this_ptr_conv;
37030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37031         this_ptr_conv.is_owned = false;
37032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37033         LDKThreeBytes val_ref;
37034         CHECK(val->arr_len == 3);
37035         memcpy(val_ref.data, val->elems, 3); FREE(val);
37036         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
37037 }
37038
37039 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
37040         LDKNodeAnnouncementInfo this_ptr_conv;
37041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37042         this_ptr_conv.is_owned = false;
37043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37044         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37045         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
37046         return ret_arr;
37047 }
37048
37049 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
37050         LDKNodeAnnouncementInfo this_ptr_conv;
37051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37052         this_ptr_conv.is_owned = false;
37053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37054         LDKThirtyTwoBytes val_ref;
37055         CHECK(val->arr_len == 32);
37056         memcpy(val_ref.data, val->elems, 32); FREE(val);
37057         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
37058 }
37059
37060 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
37061         LDKNodeAnnouncementInfo this_ptr_conv;
37062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37063         this_ptr_conv.is_owned = false;
37064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37065         LDKCVec_NetAddressZ val_constr;
37066         val_constr.datalen = val->arr_len;
37067         if (val_constr.datalen > 0)
37068                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37069         else
37070                 val_constr.data = NULL;
37071         uint32_t* val_vals = val->elems /* XXX val leaks */;
37072         for (size_t m = 0; m < val_constr.datalen; m++) {
37073                 uint32_t val_conv_12 = val_vals[m];
37074                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
37075                 CHECK_ACCESS(val_conv_12_ptr);
37076                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37077                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
37078                 val_constr.data[m] = val_conv_12_conv;
37079         }
37080         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
37081 }
37082
37083 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
37084         LDKNodeAnnouncementInfo this_ptr_conv;
37085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37086         this_ptr_conv.is_owned = false;
37087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37088         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
37089         uint32_t ret_ref = 0;
37090         if ((uintptr_t)ret_var.inner > 4096) {
37091                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37092                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37094                 ret_ref = (uintptr_t)ret_var.inner;
37095                 if (ret_var.is_owned) {
37096                         ret_ref |= 1;
37097                 }
37098         }
37099         return ret_ref;
37100 }
37101
37102 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
37103         LDKNodeAnnouncementInfo this_ptr_conv;
37104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37105         this_ptr_conv.is_owned = false;
37106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37107         LDKNodeAnnouncement val_conv;
37108         val_conv.inner = (void*)(val & (~1));
37109         val_conv.is_owned = (val & 1) || (val == 0);
37110         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37111         val_conv = NodeAnnouncement_clone(&val_conv);
37112         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
37113 }
37114
37115 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) {
37116         LDKNodeFeatures features_arg_conv;
37117         features_arg_conv.inner = (void*)(features_arg & (~1));
37118         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37119         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37120         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
37121         LDKThreeBytes rgb_arg_ref;
37122         CHECK(rgb_arg->arr_len == 3);
37123         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
37124         LDKThirtyTwoBytes alias_arg_ref;
37125         CHECK(alias_arg->arr_len == 32);
37126         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
37127         LDKCVec_NetAddressZ addresses_arg_constr;
37128         addresses_arg_constr.datalen = addresses_arg->arr_len;
37129         if (addresses_arg_constr.datalen > 0)
37130                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37131         else
37132                 addresses_arg_constr.data = NULL;
37133         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
37134         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
37135                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
37136                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
37137                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
37138                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
37139                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
37140         }
37141         LDKNodeAnnouncement announcement_message_arg_conv;
37142         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
37143         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
37144         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
37145         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
37146         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
37147         uint32_t ret_ref = 0;
37148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37151         ret_ref = (uintptr_t)ret_var.inner;
37152         if (ret_var.is_owned) {
37153                 ret_ref |= 1;
37154         }
37155         return ret_ref;
37156 }
37157
37158 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
37159         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
37160 uint32_t ret_ref = 0;
37161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37164 ret_ref = (uintptr_t)ret_var.inner;
37165 if (ret_var.is_owned) {
37166         ret_ref |= 1;
37167 }
37168         return ret_ref;
37169 }
37170 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
37171         LDKNodeAnnouncementInfo arg_conv;
37172         arg_conv.inner = (void*)(arg & (~1));
37173         arg_conv.is_owned = false;
37174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37175         uint32_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
37176         return ret_val;
37177 }
37178
37179 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
37180         LDKNodeAnnouncementInfo orig_conv;
37181         orig_conv.inner = (void*)(orig & (~1));
37182         orig_conv.is_owned = false;
37183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37184         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
37185         uint32_t ret_ref = 0;
37186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37189         ret_ref = (uintptr_t)ret_var.inner;
37190         if (ret_var.is_owned) {
37191                 ret_ref |= 1;
37192         }
37193         return ret_ref;
37194 }
37195
37196 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
37197         LDKNodeAnnouncementInfo obj_conv;
37198         obj_conv.inner = (void*)(obj & (~1));
37199         obj_conv.is_owned = false;
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37201         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
37202         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37203         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37204         CVec_u8Z_free(ret_var);
37205         return ret_arr;
37206 }
37207
37208 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
37209         LDKu8slice ser_ref;
37210         ser_ref.datalen = ser->arr_len;
37211         ser_ref.data = ser->elems /* XXX ser leaks */;
37212         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
37213         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
37214         return (uint32_t)ret_conv;
37215 }
37216
37217 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
37218         LDKNodeInfo this_obj_conv;
37219         this_obj_conv.inner = (void*)(this_obj & (~1));
37220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37222         NodeInfo_free(this_obj_conv);
37223 }
37224
37225 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
37226         LDKNodeInfo this_ptr_conv;
37227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37228         this_ptr_conv.is_owned = false;
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37230         LDKCVec_u64Z val_constr;
37231         val_constr.datalen = val->arr_len;
37232         if (val_constr.datalen > 0)
37233                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37234         else
37235                 val_constr.data = NULL;
37236         int64_t* val_vals = val->elems /* XXX val leaks */;
37237         for (size_t i = 0; i < val_constr.datalen; i++) {
37238                 int64_t val_conv_8 = val_vals[i];
37239                 val_constr.data[i] = val_conv_8;
37240         }
37241         NodeInfo_set_channels(&this_ptr_conv, val_constr);
37242 }
37243
37244 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
37245         LDKNodeInfo this_ptr_conv;
37246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37247         this_ptr_conv.is_owned = false;
37248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37249         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
37250         uint32_t ret_ref = 0;
37251         if ((uintptr_t)ret_var.inner > 4096) {
37252                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37253                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37255                 ret_ref = (uintptr_t)ret_var.inner;
37256                 if (ret_var.is_owned) {
37257                         ret_ref |= 1;
37258                 }
37259         }
37260         return ret_ref;
37261 }
37262
37263 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) {
37264         LDKNodeInfo this_ptr_conv;
37265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37266         this_ptr_conv.is_owned = false;
37267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37268         LDKRoutingFees val_conv;
37269         val_conv.inner = (void*)(val & (~1));
37270         val_conv.is_owned = (val & 1) || (val == 0);
37271         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37272         val_conv = RoutingFees_clone(&val_conv);
37273         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
37274 }
37275
37276 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
37277         LDKNodeInfo this_ptr_conv;
37278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37279         this_ptr_conv.is_owned = false;
37280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37281         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
37282         uint32_t ret_ref = 0;
37283         if ((uintptr_t)ret_var.inner > 4096) {
37284                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37285                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37287                 ret_ref = (uintptr_t)ret_var.inner;
37288                 if (ret_var.is_owned) {
37289                         ret_ref |= 1;
37290                 }
37291         }
37292         return ret_ref;
37293 }
37294
37295 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
37296         LDKNodeInfo this_ptr_conv;
37297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37298         this_ptr_conv.is_owned = false;
37299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37300         LDKNodeAnnouncementInfo val_conv;
37301         val_conv.inner = (void*)(val & (~1));
37302         val_conv.is_owned = (val & 1) || (val == 0);
37303         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37304         val_conv = NodeAnnouncementInfo_clone(&val_conv);
37305         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
37306 }
37307
37308 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) {
37309         LDKCVec_u64Z channels_arg_constr;
37310         channels_arg_constr.datalen = channels_arg->arr_len;
37311         if (channels_arg_constr.datalen > 0)
37312                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37313         else
37314                 channels_arg_constr.data = NULL;
37315         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
37316         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
37317                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
37318                 channels_arg_constr.data[i] = channels_arg_conv_8;
37319         }
37320         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
37321         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
37322         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
37323         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
37324         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
37325         LDKNodeAnnouncementInfo announcement_info_arg_conv;
37326         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
37327         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
37328         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
37329         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
37330         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
37331         uint32_t ret_ref = 0;
37332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37335         ret_ref = (uintptr_t)ret_var.inner;
37336         if (ret_var.is_owned) {
37337                 ret_ref |= 1;
37338         }
37339         return ret_ref;
37340 }
37341
37342 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
37343         LDKNodeInfo ret_var = NodeInfo_clone(arg);
37344 uint32_t ret_ref = 0;
37345 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37346 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37347 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37348 ret_ref = (uintptr_t)ret_var.inner;
37349 if (ret_var.is_owned) {
37350         ret_ref |= 1;
37351 }
37352         return ret_ref;
37353 }
37354 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
37355         LDKNodeInfo arg_conv;
37356         arg_conv.inner = (void*)(arg & (~1));
37357         arg_conv.is_owned = false;
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37359         uint32_t ret_val = NodeInfo_clone_ptr(&arg_conv);
37360         return ret_val;
37361 }
37362
37363 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
37364         LDKNodeInfo orig_conv;
37365         orig_conv.inner = (void*)(orig & (~1));
37366         orig_conv.is_owned = false;
37367         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37368         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
37369         uint32_t ret_ref = 0;
37370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37373         ret_ref = (uintptr_t)ret_var.inner;
37374         if (ret_var.is_owned) {
37375                 ret_ref |= 1;
37376         }
37377         return ret_ref;
37378 }
37379
37380 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
37381         LDKNodeInfo obj_conv;
37382         obj_conv.inner = (void*)(obj & (~1));
37383         obj_conv.is_owned = false;
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37385         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
37386         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37387         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37388         CVec_u8Z_free(ret_var);
37389         return ret_arr;
37390 }
37391
37392 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
37393         LDKu8slice ser_ref;
37394         ser_ref.datalen = ser->arr_len;
37395         ser_ref.data = ser->elems /* XXX ser leaks */;
37396         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
37397         *ret_conv = NodeInfo_read(ser_ref);
37398         return (uint32_t)ret_conv;
37399 }
37400
37401 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
37402         LDKNetworkGraph obj_conv;
37403         obj_conv.inner = (void*)(obj & (~1));
37404         obj_conv.is_owned = false;
37405         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37406         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
37407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37409         CVec_u8Z_free(ret_var);
37410         return ret_arr;
37411 }
37412
37413 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
37414         LDKu8slice ser_ref;
37415         ser_ref.datalen = ser->arr_len;
37416         ser_ref.data = ser->elems /* XXX ser leaks */;
37417         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
37418         *ret_conv = NetworkGraph_read(ser_ref);
37419         return (uint32_t)ret_conv;
37420 }
37421
37422 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
37423         LDKThirtyTwoBytes genesis_hash_ref;
37424         CHECK(genesis_hash->arr_len == 32);
37425         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
37426         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
37427         uint32_t ret_ref = 0;
37428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37431         ret_ref = (uintptr_t)ret_var.inner;
37432         if (ret_var.is_owned) {
37433                 ret_ref |= 1;
37434         }
37435         return ret_ref;
37436 }
37437
37438 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
37439         LDKNetworkGraph this_arg_conv;
37440         this_arg_conv.inner = (void*)(this_arg & (~1));
37441         this_arg_conv.is_owned = false;
37442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37443         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
37444         uint32_t ret_ref = 0;
37445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37448         ret_ref = (uintptr_t)ret_var.inner;
37449         if (ret_var.is_owned) {
37450                 ret_ref |= 1;
37451         }
37452         return ret_ref;
37453 }
37454
37455 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
37456         LDKNetworkGraph this_arg_conv;
37457         this_arg_conv.inner = (void*)(this_arg & (~1));
37458         this_arg_conv.is_owned = false;
37459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37460         LDKNodeAnnouncement msg_conv;
37461         msg_conv.inner = (void*)(msg & (~1));
37462         msg_conv.is_owned = false;
37463         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37464         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37465         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
37466         return (uint32_t)ret_conv;
37467 }
37468
37469 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) {
37470         LDKNetworkGraph this_arg_conv;
37471         this_arg_conv.inner = (void*)(this_arg & (~1));
37472         this_arg_conv.is_owned = false;
37473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37474         LDKUnsignedNodeAnnouncement msg_conv;
37475         msg_conv.inner = (void*)(msg & (~1));
37476         msg_conv.is_owned = false;
37477         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37478         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37479         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37480         return (uint32_t)ret_conv;
37481 }
37482
37483 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) {
37484         LDKNetworkGraph this_arg_conv;
37485         this_arg_conv.inner = (void*)(this_arg & (~1));
37486         this_arg_conv.is_owned = false;
37487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37488         LDKChannelAnnouncement msg_conv;
37489         msg_conv.inner = (void*)(msg & (~1));
37490         msg_conv.is_owned = false;
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37492         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37493         CHECK_ACCESS(chain_access_ptr);
37494         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37495         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37496         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37497                 // Manually implement clone for Java trait instances
37498                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37499                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37500                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37501                 }
37502         }
37503         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37504         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37505         return (uint32_t)ret_conv;
37506 }
37507
37508 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) {
37509         LDKNetworkGraph this_arg_conv;
37510         this_arg_conv.inner = (void*)(this_arg & (~1));
37511         this_arg_conv.is_owned = false;
37512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37513         LDKUnsignedChannelAnnouncement msg_conv;
37514         msg_conv.inner = (void*)(msg & (~1));
37515         msg_conv.is_owned = false;
37516         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37517         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37518         CHECK_ACCESS(chain_access_ptr);
37519         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37520         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37521         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37522                 // Manually implement clone for Java trait instances
37523                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37524                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37525                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37526                 }
37527         }
37528         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37529         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37530         return (uint32_t)ret_conv;
37531 }
37532
37533 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) {
37534         LDKNetworkGraph this_arg_conv;
37535         this_arg_conv.inner = (void*)(this_arg & (~1));
37536         this_arg_conv.is_owned = false;
37537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37538         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37539 }
37540
37541 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
37542         LDKNetworkGraph this_arg_conv;
37543         this_arg_conv.inner = (void*)(this_arg & (~1));
37544         this_arg_conv.is_owned = false;
37545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37546         LDKPublicKey _node_id_ref;
37547         CHECK(_node_id->arr_len == 33);
37548         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
37549         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37550 }
37551
37552 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) {
37553         LDKNetworkGraph this_arg_conv;
37554         this_arg_conv.inner = (void*)(this_arg & (~1));
37555         this_arg_conv.is_owned = false;
37556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37557         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37558 }
37559
37560 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
37561         LDKNetworkGraph this_arg_conv;
37562         this_arg_conv.inner = (void*)(this_arg & (~1));
37563         this_arg_conv.is_owned = false;
37564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37565         LDKChannelUpdate msg_conv;
37566         msg_conv.inner = (void*)(msg & (~1));
37567         msg_conv.is_owned = false;
37568         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37569         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37570         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37571         return (uint32_t)ret_conv;
37572 }
37573
37574 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
37575         LDKNetworkGraph this_arg_conv;
37576         this_arg_conv.inner = (void*)(this_arg & (~1));
37577         this_arg_conv.is_owned = false;
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37579         LDKUnsignedChannelUpdate msg_conv;
37580         msg_conv.inner = (void*)(msg & (~1));
37581         msg_conv.is_owned = false;
37582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37583         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37584         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37585         return (uint32_t)ret_conv;
37586 }
37587
37588 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
37589         LDKReadOnlyNetworkGraph this_arg_conv;
37590         this_arg_conv.inner = (void*)(this_arg & (~1));
37591         this_arg_conv.is_owned = false;
37592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37593         LDKPublicKey pubkey_ref;
37594         CHECK(pubkey->arr_len == 33);
37595         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37596         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37597         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37598         uint32_t ret_ref = (uintptr_t)ret_copy;
37599         return ret_ref;
37600 }
37601
37602 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
37603         LDKRouteHop this_obj_conv;
37604         this_obj_conv.inner = (void*)(this_obj & (~1));
37605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37607         RouteHop_free(this_obj_conv);
37608 }
37609
37610 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
37611         LDKRouteHop this_ptr_conv;
37612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37613         this_ptr_conv.is_owned = false;
37614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37615         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37616         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
37617         return ret_arr;
37618 }
37619
37620 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37621         LDKRouteHop this_ptr_conv;
37622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37623         this_ptr_conv.is_owned = false;
37624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37625         LDKPublicKey val_ref;
37626         CHECK(val->arr_len == 33);
37627         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37628         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37629 }
37630
37631 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37632         LDKRouteHop this_ptr_conv;
37633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37634         this_ptr_conv.is_owned = false;
37635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37636         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37637         uint32_t ret_ref = 0;
37638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37641         ret_ref = (uintptr_t)ret_var.inner;
37642         if (ret_var.is_owned) {
37643                 ret_ref |= 1;
37644         }
37645         return ret_ref;
37646 }
37647
37648 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37649         LDKRouteHop this_ptr_conv;
37650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37651         this_ptr_conv.is_owned = false;
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37653         LDKNodeFeatures val_conv;
37654         val_conv.inner = (void*)(val & (~1));
37655         val_conv.is_owned = (val & 1) || (val == 0);
37656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37657         val_conv = NodeFeatures_clone(&val_conv);
37658         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37659 }
37660
37661 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37662         LDKRouteHop this_ptr_conv;
37663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37664         this_ptr_conv.is_owned = false;
37665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37666         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37667         return ret_val;
37668 }
37669
37670 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37671         LDKRouteHop this_ptr_conv;
37672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37673         this_ptr_conv.is_owned = false;
37674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37675         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37676 }
37677
37678 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37679         LDKRouteHop this_ptr_conv;
37680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37681         this_ptr_conv.is_owned = false;
37682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37683         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37684         uint32_t ret_ref = 0;
37685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37688         ret_ref = (uintptr_t)ret_var.inner;
37689         if (ret_var.is_owned) {
37690                 ret_ref |= 1;
37691         }
37692         return ret_ref;
37693 }
37694
37695 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37696         LDKRouteHop this_ptr_conv;
37697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37698         this_ptr_conv.is_owned = false;
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37700         LDKChannelFeatures val_conv;
37701         val_conv.inner = (void*)(val & (~1));
37702         val_conv.is_owned = (val & 1) || (val == 0);
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37704         val_conv = ChannelFeatures_clone(&val_conv);
37705         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37706 }
37707
37708 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37709         LDKRouteHop this_ptr_conv;
37710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37711         this_ptr_conv.is_owned = false;
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37713         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37714         return ret_val;
37715 }
37716
37717 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37718         LDKRouteHop this_ptr_conv;
37719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37720         this_ptr_conv.is_owned = false;
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37722         RouteHop_set_fee_msat(&this_ptr_conv, val);
37723 }
37724
37725 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37726         LDKRouteHop this_ptr_conv;
37727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37728         this_ptr_conv.is_owned = false;
37729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37730         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37731         return ret_val;
37732 }
37733
37734 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37735         LDKRouteHop this_ptr_conv;
37736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37737         this_ptr_conv.is_owned = false;
37738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37739         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37740 }
37741
37742 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) {
37743         LDKPublicKey pubkey_arg_ref;
37744         CHECK(pubkey_arg->arr_len == 33);
37745         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37746         LDKNodeFeatures node_features_arg_conv;
37747         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37748         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37749         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37750         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37751         LDKChannelFeatures channel_features_arg_conv;
37752         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37753         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37754         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37755         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37756         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);
37757         uint32_t ret_ref = 0;
37758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37761         ret_ref = (uintptr_t)ret_var.inner;
37762         if (ret_var.is_owned) {
37763                 ret_ref |= 1;
37764         }
37765         return ret_ref;
37766 }
37767
37768 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37769         LDKRouteHop ret_var = RouteHop_clone(arg);
37770 uint32_t ret_ref = 0;
37771 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37772 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37773 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37774 ret_ref = (uintptr_t)ret_var.inner;
37775 if (ret_var.is_owned) {
37776         ret_ref |= 1;
37777 }
37778         return ret_ref;
37779 }
37780 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37781         LDKRouteHop arg_conv;
37782         arg_conv.inner = (void*)(arg & (~1));
37783         arg_conv.is_owned = false;
37784         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37785         uint32_t ret_val = RouteHop_clone_ptr(&arg_conv);
37786         return ret_val;
37787 }
37788
37789 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37790         LDKRouteHop orig_conv;
37791         orig_conv.inner = (void*)(orig & (~1));
37792         orig_conv.is_owned = false;
37793         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37794         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37795         uint32_t ret_ref = 0;
37796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37799         ret_ref = (uintptr_t)ret_var.inner;
37800         if (ret_var.is_owned) {
37801                 ret_ref |= 1;
37802         }
37803         return ret_ref;
37804 }
37805
37806 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37807         LDKRouteHop o_conv;
37808         o_conv.inner = (void*)(o & (~1));
37809         o_conv.is_owned = false;
37810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37811         int64_t ret_val = RouteHop_hash(&o_conv);
37812         return ret_val;
37813 }
37814
37815 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37816         LDKRouteHop a_conv;
37817         a_conv.inner = (void*)(a & (~1));
37818         a_conv.is_owned = false;
37819         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37820         LDKRouteHop b_conv;
37821         b_conv.inner = (void*)(b & (~1));
37822         b_conv.is_owned = false;
37823         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37824         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37825         return ret_val;
37826 }
37827
37828 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37829         LDKRouteHop obj_conv;
37830         obj_conv.inner = (void*)(obj & (~1));
37831         obj_conv.is_owned = false;
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37833         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37834         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37835         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37836         CVec_u8Z_free(ret_var);
37837         return ret_arr;
37838 }
37839
37840 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37841         LDKu8slice ser_ref;
37842         ser_ref.datalen = ser->arr_len;
37843         ser_ref.data = ser->elems /* XXX ser leaks */;
37844         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37845         *ret_conv = RouteHop_read(ser_ref);
37846         return (uint32_t)ret_conv;
37847 }
37848
37849 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37850         LDKRoute this_obj_conv;
37851         this_obj_conv.inner = (void*)(this_obj & (~1));
37852         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37854         Route_free(this_obj_conv);
37855 }
37856
37857 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37858         LDKRoute this_ptr_conv;
37859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37860         this_ptr_conv.is_owned = false;
37861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37862         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37863         ptrArray ret_arr = NULL;
37864         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37865         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37866         for (size_t m = 0; m < ret_var.datalen; m++) {
37867                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37868                 uint32_tArray ret_conv_12_arr = NULL;
37869                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37870                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37871                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37872                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37873                         uint32_t ret_conv_12_conv_10_ref = 0;
37874                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37875                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37876                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37877                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37878                         if (ret_conv_12_conv_10_var.is_owned) {
37879                                 ret_conv_12_conv_10_ref |= 1;
37880                         }
37881                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37882                 }
37883                 
37884                 FREE(ret_conv_12_var.data);
37885                 ret_arr_ptr[m] = ret_conv_12_arr;
37886         }
37887         
37888         FREE(ret_var.data);
37889         return ret_arr;
37890 }
37891
37892 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37893         LDKRoute this_ptr_conv;
37894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37895         this_ptr_conv.is_owned = false;
37896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37897         LDKCVec_CVec_RouteHopZZ val_constr;
37898         val_constr.datalen = val->arr_len;
37899         if (val_constr.datalen > 0)
37900                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37901         else
37902                 val_constr.data = NULL;
37903         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37904         for (size_t m = 0; m < val_constr.datalen; m++) {
37905                 uint32_tArray val_conv_12 = val_vals[m];
37906                 LDKCVec_RouteHopZ val_conv_12_constr;
37907                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37908                 if (val_conv_12_constr.datalen > 0)
37909                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37910                 else
37911                         val_conv_12_constr.data = NULL;
37912                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37913                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37914                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37915                         LDKRouteHop val_conv_12_conv_10_conv;
37916                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37917                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37918                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37919                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37920                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37921                 }
37922                 val_constr.data[m] = val_conv_12_constr;
37923         }
37924         Route_set_paths(&this_ptr_conv, val_constr);
37925 }
37926
37927 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37928         LDKRoute this_ptr_conv;
37929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37930         this_ptr_conv.is_owned = false;
37931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37932         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37933         uint32_t ret_ref = 0;
37934         if ((uintptr_t)ret_var.inner > 4096) {
37935                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37936                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37938                 ret_ref = (uintptr_t)ret_var.inner;
37939                 if (ret_var.is_owned) {
37940                         ret_ref |= 1;
37941                 }
37942         }
37943         return ret_ref;
37944 }
37945
37946 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
37947         LDKRoute this_ptr_conv;
37948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37949         this_ptr_conv.is_owned = false;
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37951         LDKPaymentParameters val_conv;
37952         val_conv.inner = (void*)(val & (~1));
37953         val_conv.is_owned = (val & 1) || (val == 0);
37954         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37955         val_conv = PaymentParameters_clone(&val_conv);
37956         Route_set_payment_params(&this_ptr_conv, val_conv);
37957 }
37958
37959 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
37960         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37961         paths_arg_constr.datalen = paths_arg->arr_len;
37962         if (paths_arg_constr.datalen > 0)
37963                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37964         else
37965                 paths_arg_constr.data = NULL;
37966         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
37967         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37968                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
37969                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37970                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
37971                 if (paths_arg_conv_12_constr.datalen > 0)
37972                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37973                 else
37974                         paths_arg_conv_12_constr.data = NULL;
37975                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
37976                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37977                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37978                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37979                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37980                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37981                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37982                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37983                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37984                 }
37985                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37986         }
37987         LDKPaymentParameters payment_params_arg_conv;
37988         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37989         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37991         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37992         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
37993         uint32_t ret_ref = 0;
37994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37997         ret_ref = (uintptr_t)ret_var.inner;
37998         if (ret_var.is_owned) {
37999                 ret_ref |= 1;
38000         }
38001         return ret_ref;
38002 }
38003
38004 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
38005         LDKRoute ret_var = Route_clone(arg);
38006 uint32_t ret_ref = 0;
38007 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38008 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38009 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38010 ret_ref = (uintptr_t)ret_var.inner;
38011 if (ret_var.is_owned) {
38012         ret_ref |= 1;
38013 }
38014         return ret_ref;
38015 }
38016 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
38017         LDKRoute arg_conv;
38018         arg_conv.inner = (void*)(arg & (~1));
38019         arg_conv.is_owned = false;
38020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38021         uint32_t ret_val = Route_clone_ptr(&arg_conv);
38022         return ret_val;
38023 }
38024
38025 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
38026         LDKRoute orig_conv;
38027         orig_conv.inner = (void*)(orig & (~1));
38028         orig_conv.is_owned = false;
38029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38030         LDKRoute ret_var = Route_clone(&orig_conv);
38031         uint32_t ret_ref = 0;
38032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38035         ret_ref = (uintptr_t)ret_var.inner;
38036         if (ret_var.is_owned) {
38037                 ret_ref |= 1;
38038         }
38039         return ret_ref;
38040 }
38041
38042 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
38043         LDKRoute o_conv;
38044         o_conv.inner = (void*)(o & (~1));
38045         o_conv.is_owned = false;
38046         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38047         int64_t ret_val = Route_hash(&o_conv);
38048         return ret_val;
38049 }
38050
38051 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
38052         LDKRoute a_conv;
38053         a_conv.inner = (void*)(a & (~1));
38054         a_conv.is_owned = false;
38055         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38056         LDKRoute b_conv;
38057         b_conv.inner = (void*)(b & (~1));
38058         b_conv.is_owned = false;
38059         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38060         jboolean ret_val = Route_eq(&a_conv, &b_conv);
38061         return ret_val;
38062 }
38063
38064 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
38065         LDKRoute this_arg_conv;
38066         this_arg_conv.inner = (void*)(this_arg & (~1));
38067         this_arg_conv.is_owned = false;
38068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38069         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
38070         return ret_val;
38071 }
38072
38073 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
38074         LDKRoute this_arg_conv;
38075         this_arg_conv.inner = (void*)(this_arg & (~1));
38076         this_arg_conv.is_owned = false;
38077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38078         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
38079         return ret_val;
38080 }
38081
38082 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
38083         LDKRoute obj_conv;
38084         obj_conv.inner = (void*)(obj & (~1));
38085         obj_conv.is_owned = false;
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38087         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
38088         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38089         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38090         CVec_u8Z_free(ret_var);
38091         return ret_arr;
38092 }
38093
38094 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
38095         LDKu8slice ser_ref;
38096         ser_ref.datalen = ser->arr_len;
38097         ser_ref.data = ser->elems /* XXX ser leaks */;
38098         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
38099         *ret_conv = Route_read(ser_ref);
38100         return (uint32_t)ret_conv;
38101 }
38102
38103 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
38104         LDKRouteParameters this_obj_conv;
38105         this_obj_conv.inner = (void*)(this_obj & (~1));
38106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38108         RouteParameters_free(this_obj_conv);
38109 }
38110
38111 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
38112         LDKRouteParameters this_ptr_conv;
38113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38114         this_ptr_conv.is_owned = false;
38115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38116         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
38117         uint32_t ret_ref = 0;
38118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38121         ret_ref = (uintptr_t)ret_var.inner;
38122         if (ret_var.is_owned) {
38123                 ret_ref |= 1;
38124         }
38125         return ret_ref;
38126 }
38127
38128 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
38129         LDKRouteParameters this_ptr_conv;
38130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38131         this_ptr_conv.is_owned = false;
38132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38133         LDKPaymentParameters val_conv;
38134         val_conv.inner = (void*)(val & (~1));
38135         val_conv.is_owned = (val & 1) || (val == 0);
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38137         val_conv = PaymentParameters_clone(&val_conv);
38138         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
38139 }
38140
38141 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
38142         LDKRouteParameters this_ptr_conv;
38143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38144         this_ptr_conv.is_owned = false;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38146         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
38147         return ret_val;
38148 }
38149
38150 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
38151         LDKRouteParameters this_ptr_conv;
38152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38153         this_ptr_conv.is_owned = false;
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38155         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
38156 }
38157
38158 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
38159         LDKRouteParameters this_ptr_conv;
38160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38161         this_ptr_conv.is_owned = false;
38162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38163         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
38164         return ret_val;
38165 }
38166
38167 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) {
38168         LDKRouteParameters this_ptr_conv;
38169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38170         this_ptr_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38172         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
38173 }
38174
38175 uint32_t  __attribute__((export_name("TS_RouteParameters_new"))) TS_RouteParameters_new(uint32_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
38176         LDKPaymentParameters payment_params_arg_conv;
38177         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38178         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38180         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38181         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
38182         uint32_t ret_ref = 0;
38183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38186         ret_ref = (uintptr_t)ret_var.inner;
38187         if (ret_var.is_owned) {
38188                 ret_ref |= 1;
38189         }
38190         return ret_ref;
38191 }
38192
38193 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
38194         LDKRouteParameters ret_var = RouteParameters_clone(arg);
38195 uint32_t ret_ref = 0;
38196 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38197 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38198 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38199 ret_ref = (uintptr_t)ret_var.inner;
38200 if (ret_var.is_owned) {
38201         ret_ref |= 1;
38202 }
38203         return ret_ref;
38204 }
38205 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
38206         LDKRouteParameters arg_conv;
38207         arg_conv.inner = (void*)(arg & (~1));
38208         arg_conv.is_owned = false;
38209         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38210         uint32_t ret_val = RouteParameters_clone_ptr(&arg_conv);
38211         return ret_val;
38212 }
38213
38214 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
38215         LDKRouteParameters orig_conv;
38216         orig_conv.inner = (void*)(orig & (~1));
38217         orig_conv.is_owned = false;
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38219         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
38220         uint32_t ret_ref = 0;
38221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38224         ret_ref = (uintptr_t)ret_var.inner;
38225         if (ret_var.is_owned) {
38226                 ret_ref |= 1;
38227         }
38228         return ret_ref;
38229 }
38230
38231 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
38232         LDKRouteParameters obj_conv;
38233         obj_conv.inner = (void*)(obj & (~1));
38234         obj_conv.is_owned = false;
38235         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38236         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
38237         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38238         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38239         CVec_u8Z_free(ret_var);
38240         return ret_arr;
38241 }
38242
38243 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
38244         LDKu8slice ser_ref;
38245         ser_ref.datalen = ser->arr_len;
38246         ser_ref.data = ser->elems /* XXX ser leaks */;
38247         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
38248         *ret_conv = RouteParameters_read(ser_ref);
38249         return (uint32_t)ret_conv;
38250 }
38251
38252 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
38253         LDKPaymentParameters this_obj_conv;
38254         this_obj_conv.inner = (void*)(this_obj & (~1));
38255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38257         PaymentParameters_free(this_obj_conv);
38258 }
38259
38260 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
38261         LDKPaymentParameters this_ptr_conv;
38262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38263         this_ptr_conv.is_owned = false;
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38265         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38266         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
38267         return ret_arr;
38268 }
38269
38270 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
38271         LDKPaymentParameters this_ptr_conv;
38272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38273         this_ptr_conv.is_owned = false;
38274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38275         LDKPublicKey val_ref;
38276         CHECK(val->arr_len == 33);
38277         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38278         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
38279 }
38280
38281 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
38282         LDKPaymentParameters this_ptr_conv;
38283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38284         this_ptr_conv.is_owned = false;
38285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38286         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
38287         uint32_t ret_ref = 0;
38288         if ((uintptr_t)ret_var.inner > 4096) {
38289                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38290                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38292                 ret_ref = (uintptr_t)ret_var.inner;
38293                 if (ret_var.is_owned) {
38294                         ret_ref |= 1;
38295                 }
38296         }
38297         return ret_ref;
38298 }
38299
38300 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
38301         LDKPaymentParameters this_ptr_conv;
38302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38303         this_ptr_conv.is_owned = false;
38304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38305         LDKInvoiceFeatures val_conv;
38306         val_conv.inner = (void*)(val & (~1));
38307         val_conv.is_owned = (val & 1) || (val == 0);
38308         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38309         val_conv = InvoiceFeatures_clone(&val_conv);
38310         PaymentParameters_set_features(&this_ptr_conv, val_conv);
38311 }
38312
38313 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
38314         LDKPaymentParameters this_ptr_conv;
38315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38316         this_ptr_conv.is_owned = false;
38317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38318         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
38319         uint32_tArray ret_arr = NULL;
38320         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38321         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38322         for (size_t l = 0; l < ret_var.datalen; l++) {
38323                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
38324                 uint32_t ret_conv_11_ref = 0;
38325                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38326                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38327                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
38328                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
38329                 if (ret_conv_11_var.is_owned) {
38330                         ret_conv_11_ref |= 1;
38331                 }
38332                 ret_arr_ptr[l] = ret_conv_11_ref;
38333         }
38334         
38335         FREE(ret_var.data);
38336         return ret_arr;
38337 }
38338
38339 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
38340         LDKPaymentParameters this_ptr_conv;
38341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38342         this_ptr_conv.is_owned = false;
38343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38344         LDKCVec_RouteHintZ val_constr;
38345         val_constr.datalen = val->arr_len;
38346         if (val_constr.datalen > 0)
38347                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38348         else
38349                 val_constr.data = NULL;
38350         uint32_t* val_vals = val->elems /* XXX val leaks */;
38351         for (size_t l = 0; l < val_constr.datalen; l++) {
38352                 uint32_t val_conv_11 = val_vals[l];
38353                 LDKRouteHint val_conv_11_conv;
38354                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
38355                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
38356                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
38357                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
38358                 val_constr.data[l] = val_conv_11_conv;
38359         }
38360         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
38361 }
38362
38363 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
38364         LDKPaymentParameters this_ptr_conv;
38365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38366         this_ptr_conv.is_owned = false;
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38368         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38369         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
38370         uint32_t ret_ref = (uintptr_t)ret_copy;
38371         return ret_ref;
38372 }
38373
38374 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
38375         LDKPaymentParameters this_ptr_conv;
38376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38377         this_ptr_conv.is_owned = false;
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38380         CHECK_ACCESS(val_ptr);
38381         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38382         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38383         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
38384 }
38385
38386 int32_t  __attribute__((export_name("TS_PaymentParameters_get_max_total_cltv_expiry_delta"))) TS_PaymentParameters_get_max_total_cltv_expiry_delta(uint32_t this_ptr) {
38387         LDKPaymentParameters this_ptr_conv;
38388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38389         this_ptr_conv.is_owned = false;
38390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38391         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
38392         return ret_val;
38393 }
38394
38395 void  __attribute__((export_name("TS_PaymentParameters_set_max_total_cltv_expiry_delta"))) TS_PaymentParameters_set_max_total_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
38396         LDKPaymentParameters this_ptr_conv;
38397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38398         this_ptr_conv.is_owned = false;
38399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38400         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
38401 }
38402
38403 uint32_t  __attribute__((export_name("TS_PaymentParameters_new"))) TS_PaymentParameters_new(int8_tArray payee_pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg) {
38404         LDKPublicKey payee_pubkey_arg_ref;
38405         CHECK(payee_pubkey_arg->arr_len == 33);
38406         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
38407         LDKInvoiceFeatures features_arg_conv;
38408         features_arg_conv.inner = (void*)(features_arg & (~1));
38409         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
38411         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
38412         LDKCVec_RouteHintZ route_hints_arg_constr;
38413         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
38414         if (route_hints_arg_constr.datalen > 0)
38415                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38416         else
38417                 route_hints_arg_constr.data = NULL;
38418         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
38419         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
38420                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
38421                 LDKRouteHint route_hints_arg_conv_11_conv;
38422                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
38423                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
38424                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
38425                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
38426                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
38427         }
38428         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
38429         CHECK_ACCESS(expiry_time_arg_ptr);
38430         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
38431         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
38432         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg);
38433         uint32_t ret_ref = 0;
38434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38437         ret_ref = (uintptr_t)ret_var.inner;
38438         if (ret_var.is_owned) {
38439                 ret_ref |= 1;
38440         }
38441         return ret_ref;
38442 }
38443
38444 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
38445         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
38446 uint32_t ret_ref = 0;
38447 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38448 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38449 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38450 ret_ref = (uintptr_t)ret_var.inner;
38451 if (ret_var.is_owned) {
38452         ret_ref |= 1;
38453 }
38454         return ret_ref;
38455 }
38456 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
38457         LDKPaymentParameters arg_conv;
38458         arg_conv.inner = (void*)(arg & (~1));
38459         arg_conv.is_owned = false;
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38461         uint32_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
38462         return ret_val;
38463 }
38464
38465 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
38466         LDKPaymentParameters orig_conv;
38467         orig_conv.inner = (void*)(orig & (~1));
38468         orig_conv.is_owned = false;
38469         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38470         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
38471         uint32_t ret_ref = 0;
38472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38475         ret_ref = (uintptr_t)ret_var.inner;
38476         if (ret_var.is_owned) {
38477                 ret_ref |= 1;
38478         }
38479         return ret_ref;
38480 }
38481
38482 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
38483         LDKPaymentParameters o_conv;
38484         o_conv.inner = (void*)(o & (~1));
38485         o_conv.is_owned = false;
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38487         int64_t ret_val = PaymentParameters_hash(&o_conv);
38488         return ret_val;
38489 }
38490
38491 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
38492         LDKPaymentParameters a_conv;
38493         a_conv.inner = (void*)(a & (~1));
38494         a_conv.is_owned = false;
38495         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38496         LDKPaymentParameters b_conv;
38497         b_conv.inner = (void*)(b & (~1));
38498         b_conv.is_owned = false;
38499         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38500         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
38501         return ret_val;
38502 }
38503
38504 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
38505         LDKPaymentParameters obj_conv;
38506         obj_conv.inner = (void*)(obj & (~1));
38507         obj_conv.is_owned = false;
38508         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38509         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
38510         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38511         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38512         CVec_u8Z_free(ret_var);
38513         return ret_arr;
38514 }
38515
38516 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
38517         LDKu8slice ser_ref;
38518         ser_ref.datalen = ser->arr_len;
38519         ser_ref.data = ser->elems /* XXX ser leaks */;
38520         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
38521         *ret_conv = PaymentParameters_read(ser_ref);
38522         return (uint32_t)ret_conv;
38523 }
38524
38525 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
38526         LDKPublicKey payee_pubkey_ref;
38527         CHECK(payee_pubkey->arr_len == 33);
38528         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38529         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
38530         uint32_t ret_ref = 0;
38531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38534         ret_ref = (uintptr_t)ret_var.inner;
38535         if (ret_var.is_owned) {
38536                 ret_ref |= 1;
38537         }
38538         return ret_ref;
38539 }
38540
38541 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
38542         LDKPublicKey payee_pubkey_ref;
38543         CHECK(payee_pubkey->arr_len == 33);
38544         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38545         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
38546         uint32_t ret_ref = 0;
38547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38550         ret_ref = (uintptr_t)ret_var.inner;
38551         if (ret_var.is_owned) {
38552                 ret_ref |= 1;
38553         }
38554         return ret_ref;
38555 }
38556
38557 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
38558         LDKRouteHint this_obj_conv;
38559         this_obj_conv.inner = (void*)(this_obj & (~1));
38560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38562         RouteHint_free(this_obj_conv);
38563 }
38564
38565 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
38566         LDKRouteHint this_ptr_conv;
38567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38568         this_ptr_conv.is_owned = false;
38569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38570         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38571         uint32_tArray ret_arr = NULL;
38572         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38573         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38574         for (size_t o = 0; o < ret_var.datalen; o++) {
38575                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38576                 uint32_t ret_conv_14_ref = 0;
38577                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38578                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38579                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38580                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
38581                 if (ret_conv_14_var.is_owned) {
38582                         ret_conv_14_ref |= 1;
38583                 }
38584                 ret_arr_ptr[o] = ret_conv_14_ref;
38585         }
38586         
38587         FREE(ret_var.data);
38588         return ret_arr;
38589 }
38590
38591 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
38592         LDKRouteHint this_ptr_conv;
38593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38594         this_ptr_conv.is_owned = false;
38595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38596         LDKCVec_RouteHintHopZ val_constr;
38597         val_constr.datalen = val->arr_len;
38598         if (val_constr.datalen > 0)
38599                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38600         else
38601                 val_constr.data = NULL;
38602         uint32_t* val_vals = val->elems /* XXX val leaks */;
38603         for (size_t o = 0; o < val_constr.datalen; o++) {
38604                 uint32_t val_conv_14 = val_vals[o];
38605                 LDKRouteHintHop val_conv_14_conv;
38606                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38607                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38608                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38609                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38610                 val_constr.data[o] = val_conv_14_conv;
38611         }
38612         RouteHint_set_a(&this_ptr_conv, val_constr);
38613 }
38614
38615 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
38616         LDKCVec_RouteHintHopZ a_arg_constr;
38617         a_arg_constr.datalen = a_arg->arr_len;
38618         if (a_arg_constr.datalen > 0)
38619                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38620         else
38621                 a_arg_constr.data = NULL;
38622         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38623         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38624                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38625                 LDKRouteHintHop a_arg_conv_14_conv;
38626                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38627                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38628                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38629                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38630                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38631         }
38632         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38633         uint32_t ret_ref = 0;
38634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38637         ret_ref = (uintptr_t)ret_var.inner;
38638         if (ret_var.is_owned) {
38639                 ret_ref |= 1;
38640         }
38641         return ret_ref;
38642 }
38643
38644 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38645         LDKRouteHint ret_var = RouteHint_clone(arg);
38646 uint32_t ret_ref = 0;
38647 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38648 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38649 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38650 ret_ref = (uintptr_t)ret_var.inner;
38651 if (ret_var.is_owned) {
38652         ret_ref |= 1;
38653 }
38654         return ret_ref;
38655 }
38656 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38657         LDKRouteHint arg_conv;
38658         arg_conv.inner = (void*)(arg & (~1));
38659         arg_conv.is_owned = false;
38660         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38661         uint32_t ret_val = RouteHint_clone_ptr(&arg_conv);
38662         return ret_val;
38663 }
38664
38665 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38666         LDKRouteHint orig_conv;
38667         orig_conv.inner = (void*)(orig & (~1));
38668         orig_conv.is_owned = false;
38669         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38670         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38671         uint32_t ret_ref = 0;
38672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38675         ret_ref = (uintptr_t)ret_var.inner;
38676         if (ret_var.is_owned) {
38677                 ret_ref |= 1;
38678         }
38679         return ret_ref;
38680 }
38681
38682 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38683         LDKRouteHint o_conv;
38684         o_conv.inner = (void*)(o & (~1));
38685         o_conv.is_owned = false;
38686         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38687         int64_t ret_val = RouteHint_hash(&o_conv);
38688         return ret_val;
38689 }
38690
38691 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38692         LDKRouteHint a_conv;
38693         a_conv.inner = (void*)(a & (~1));
38694         a_conv.is_owned = false;
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38696         LDKRouteHint b_conv;
38697         b_conv.inner = (void*)(b & (~1));
38698         b_conv.is_owned = false;
38699         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38700         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38701         return ret_val;
38702 }
38703
38704 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38705         LDKRouteHint obj_conv;
38706         obj_conv.inner = (void*)(obj & (~1));
38707         obj_conv.is_owned = false;
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38709         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38710         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38711         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38712         CVec_u8Z_free(ret_var);
38713         return ret_arr;
38714 }
38715
38716 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38717         LDKu8slice ser_ref;
38718         ser_ref.datalen = ser->arr_len;
38719         ser_ref.data = ser->elems /* XXX ser leaks */;
38720         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38721         *ret_conv = RouteHint_read(ser_ref);
38722         return (uint32_t)ret_conv;
38723 }
38724
38725 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38726         LDKRouteHintHop this_obj_conv;
38727         this_obj_conv.inner = (void*)(this_obj & (~1));
38728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38730         RouteHintHop_free(this_obj_conv);
38731 }
38732
38733 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38734         LDKRouteHintHop this_ptr_conv;
38735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38736         this_ptr_conv.is_owned = false;
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38738         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38739         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38740         return ret_arr;
38741 }
38742
38743 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38744         LDKRouteHintHop this_ptr_conv;
38745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38746         this_ptr_conv.is_owned = false;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38748         LDKPublicKey val_ref;
38749         CHECK(val->arr_len == 33);
38750         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38751         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38752 }
38753
38754 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38755         LDKRouteHintHop this_ptr_conv;
38756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38757         this_ptr_conv.is_owned = false;
38758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38759         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38760         return ret_val;
38761 }
38762
38763 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38764         LDKRouteHintHop this_ptr_conv;
38765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38766         this_ptr_conv.is_owned = false;
38767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38768         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38769 }
38770
38771 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38772         LDKRouteHintHop this_ptr_conv;
38773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38774         this_ptr_conv.is_owned = false;
38775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38776         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38777         uint32_t ret_ref = 0;
38778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38781         ret_ref = (uintptr_t)ret_var.inner;
38782         if (ret_var.is_owned) {
38783                 ret_ref |= 1;
38784         }
38785         return ret_ref;
38786 }
38787
38788 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38789         LDKRouteHintHop this_ptr_conv;
38790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38791         this_ptr_conv.is_owned = false;
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38793         LDKRoutingFees val_conv;
38794         val_conv.inner = (void*)(val & (~1));
38795         val_conv.is_owned = (val & 1) || (val == 0);
38796         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38797         val_conv = RoutingFees_clone(&val_conv);
38798         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38799 }
38800
38801 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38802         LDKRouteHintHop this_ptr_conv;
38803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38804         this_ptr_conv.is_owned = false;
38805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38806         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38807         return ret_val;
38808 }
38809
38810 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38811         LDKRouteHintHop this_ptr_conv;
38812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38813         this_ptr_conv.is_owned = false;
38814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38815         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38816 }
38817
38818 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38819         LDKRouteHintHop this_ptr_conv;
38820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38821         this_ptr_conv.is_owned = false;
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38823         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38824         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38825         uint32_t ret_ref = (uintptr_t)ret_copy;
38826         return ret_ref;
38827 }
38828
38829 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38830         LDKRouteHintHop this_ptr_conv;
38831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38832         this_ptr_conv.is_owned = false;
38833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38834         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38835         CHECK_ACCESS(val_ptr);
38836         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38837         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38838         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38839 }
38840
38841 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38842         LDKRouteHintHop this_ptr_conv;
38843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38844         this_ptr_conv.is_owned = false;
38845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38846         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38847         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38848         uint32_t ret_ref = (uintptr_t)ret_copy;
38849         return ret_ref;
38850 }
38851
38852 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38853         LDKRouteHintHop this_ptr_conv;
38854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38855         this_ptr_conv.is_owned = false;
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38857         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38858         CHECK_ACCESS(val_ptr);
38859         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38860         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38861         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38862 }
38863
38864 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) {
38865         LDKPublicKey src_node_id_arg_ref;
38866         CHECK(src_node_id_arg->arr_len == 33);
38867         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38868         LDKRoutingFees fees_arg_conv;
38869         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38870         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38871         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38872         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38873         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38874         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38875         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38876         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38877         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38878         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38879         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38880         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38881         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);
38882         uint32_t ret_ref = 0;
38883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38886         ret_ref = (uintptr_t)ret_var.inner;
38887         if (ret_var.is_owned) {
38888                 ret_ref |= 1;
38889         }
38890         return ret_ref;
38891 }
38892
38893 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38894         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38895 uint32_t ret_ref = 0;
38896 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38897 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38898 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38899 ret_ref = (uintptr_t)ret_var.inner;
38900 if (ret_var.is_owned) {
38901         ret_ref |= 1;
38902 }
38903         return ret_ref;
38904 }
38905 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38906         LDKRouteHintHop arg_conv;
38907         arg_conv.inner = (void*)(arg & (~1));
38908         arg_conv.is_owned = false;
38909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38910         uint32_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38911         return ret_val;
38912 }
38913
38914 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38915         LDKRouteHintHop orig_conv;
38916         orig_conv.inner = (void*)(orig & (~1));
38917         orig_conv.is_owned = false;
38918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38919         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38920         uint32_t ret_ref = 0;
38921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38924         ret_ref = (uintptr_t)ret_var.inner;
38925         if (ret_var.is_owned) {
38926                 ret_ref |= 1;
38927         }
38928         return ret_ref;
38929 }
38930
38931 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38932         LDKRouteHintHop o_conv;
38933         o_conv.inner = (void*)(o & (~1));
38934         o_conv.is_owned = false;
38935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38936         int64_t ret_val = RouteHintHop_hash(&o_conv);
38937         return ret_val;
38938 }
38939
38940 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
38941         LDKRouteHintHop a_conv;
38942         a_conv.inner = (void*)(a & (~1));
38943         a_conv.is_owned = false;
38944         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38945         LDKRouteHintHop b_conv;
38946         b_conv.inner = (void*)(b & (~1));
38947         b_conv.is_owned = false;
38948         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38949         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38950         return ret_val;
38951 }
38952
38953 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
38954         LDKRouteHintHop obj_conv;
38955         obj_conv.inner = (void*)(obj & (~1));
38956         obj_conv.is_owned = false;
38957         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38958         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38959         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38960         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38961         CVec_u8Z_free(ret_var);
38962         return ret_arr;
38963 }
38964
38965 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
38966         LDKu8slice ser_ref;
38967         ser_ref.datalen = ser->arr_len;
38968         ser_ref.data = ser->elems /* XXX ser leaks */;
38969         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38970         *ret_conv = RouteHintHop_read(ser_ref);
38971         return (uint32_t)ret_conv;
38972 }
38973
38974 uint32_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t route_params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer, int8_tArray random_seed_bytes) {
38975         LDKPublicKey our_node_pubkey_ref;
38976         CHECK(our_node_pubkey->arr_len == 33);
38977         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
38978         LDKRouteParameters route_params_conv;
38979         route_params_conv.inner = (void*)(route_params & (~1));
38980         route_params_conv.is_owned = false;
38981         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
38982         LDKNetworkGraph network_conv;
38983         network_conv.inner = (void*)(network & (~1));
38984         network_conv.is_owned = false;
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38986         LDKCVec_ChannelDetailsZ first_hops_constr;
38987         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38988         if (first_hops != 0) {
38989                 first_hops_constr.datalen = first_hops->arr_len;
38990                 if (first_hops_constr.datalen > 0)
38991                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38992                 else
38993                         first_hops_constr.data = NULL;
38994                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
38995                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38996                         uint32_t first_hops_conv_16 = first_hops_vals[q];
38997                         LDKChannelDetails first_hops_conv_16_conv;
38998                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38999                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
39000                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
39001                         first_hops_constr.data[q] = first_hops_conv_16_conv;
39002                 }
39003                 first_hops_ptr = &first_hops_constr;
39004         }
39005         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39006         CHECK_ACCESS(logger_ptr);
39007         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39008         if (logger_conv.free == LDKLogger_JCalls_free) {
39009                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39010                 LDKLogger_JCalls_cloned(&logger_conv);
39011         }
39012         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
39013         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
39014         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
39015         unsigned char random_seed_bytes_arr[32];
39016         CHECK(random_seed_bytes->arr_len == 32);
39017         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
39018         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
39019         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
39020         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
39021         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
39022         return (uint32_t)ret_conv;
39023 }
39024
39025 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
39026         if ((this_ptr & 1) != 0) return;
39027         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39028         CHECK_ACCESS(this_ptr_ptr);
39029         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
39030         FREE((void*)this_ptr);
39031         Score_free(this_ptr_conv);
39032 }
39033
39034 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
39035         if ((this_ptr & 1) != 0) return;
39036         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39037         CHECK_ACCESS(this_ptr_ptr);
39038         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
39039         FREE((void*)this_ptr);
39040         LockableScore_free(this_ptr_conv);
39041 }
39042
39043 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
39044         LDKMultiThreadedLockableScore this_obj_conv;
39045         this_obj_conv.inner = (void*)(this_obj & (~1));
39046         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39048         MultiThreadedLockableScore_free(this_obj_conv);
39049 }
39050
39051 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
39052         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
39053         CHECK_ACCESS(score_ptr);
39054         LDKScore score_conv = *(LDKScore*)(score_ptr);
39055         if (score_conv.free == LDKScore_JCalls_free) {
39056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39057                 LDKScore_JCalls_cloned(&score_conv);
39058         }
39059         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
39060         uint32_t ret_ref = 0;
39061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39064         ret_ref = (uintptr_t)ret_var.inner;
39065         if (ret_var.is_owned) {
39066                 ret_ref |= 1;
39067         }
39068         return ret_ref;
39069 }
39070
39071 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
39072         LDKFixedPenaltyScorer this_obj_conv;
39073         this_obj_conv.inner = (void*)(this_obj & (~1));
39074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39076         FixedPenaltyScorer_free(this_obj_conv);
39077 }
39078
39079 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
39080         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
39081 uint32_t ret_ref = 0;
39082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39085 ret_ref = (uintptr_t)ret_var.inner;
39086 if (ret_var.is_owned) {
39087         ret_ref |= 1;
39088 }
39089         return ret_ref;
39090 }
39091 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
39092         LDKFixedPenaltyScorer arg_conv;
39093         arg_conv.inner = (void*)(arg & (~1));
39094         arg_conv.is_owned = false;
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39096         uint32_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
39097         return ret_val;
39098 }
39099
39100 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
39101         LDKFixedPenaltyScorer orig_conv;
39102         orig_conv.inner = (void*)(orig & (~1));
39103         orig_conv.is_owned = false;
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39105         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
39106         uint32_t ret_ref = 0;
39107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39110         ret_ref = (uintptr_t)ret_var.inner;
39111         if (ret_var.is_owned) {
39112                 ret_ref |= 1;
39113         }
39114         return ret_ref;
39115 }
39116
39117 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
39118         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
39119         uint32_t ret_ref = 0;
39120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39123         ret_ref = (uintptr_t)ret_var.inner;
39124         if (ret_var.is_owned) {
39125                 ret_ref |= 1;
39126         }
39127         return ret_ref;
39128 }
39129
39130 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
39131         LDKFixedPenaltyScorer this_arg_conv;
39132         this_arg_conv.inner = (void*)(this_arg & (~1));
39133         this_arg_conv.is_owned = false;
39134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39135         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39136         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
39137         return (uint32_t)ret_ret;
39138 }
39139
39140 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
39141         LDKFixedPenaltyScorer obj_conv;
39142         obj_conv.inner = (void*)(obj & (~1));
39143         obj_conv.is_owned = false;
39144         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39145         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
39146         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39147         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39148         CVec_u8Z_free(ret_var);
39149         return ret_arr;
39150 }
39151
39152 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
39153         LDKu8slice ser_ref;
39154         ser_ref.datalen = ser->arr_len;
39155         ser_ref.data = ser->elems /* XXX ser leaks */;
39156         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
39157         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
39158         return (uint32_t)ret_conv;
39159 }
39160
39161 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
39162         LDKScorer this_obj_conv;
39163         this_obj_conv.inner = (void*)(this_obj & (~1));
39164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39166         Scorer_free(this_obj_conv);
39167 }
39168
39169 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
39170         LDKScoringParameters this_obj_conv;
39171         this_obj_conv.inner = (void*)(this_obj & (~1));
39172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39174         ScoringParameters_free(this_obj_conv);
39175 }
39176
39177 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39178         LDKScoringParameters this_ptr_conv;
39179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39180         this_ptr_conv.is_owned = false;
39181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39182         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39183         return ret_val;
39184 }
39185
39186 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39187         LDKScoringParameters this_ptr_conv;
39188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39189         this_ptr_conv.is_owned = false;
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39191         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39192 }
39193
39194 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
39195         LDKScoringParameters this_ptr_conv;
39196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39197         this_ptr_conv.is_owned = false;
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39199         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
39200         return ret_val;
39201 }
39202
39203 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
39204         LDKScoringParameters this_ptr_conv;
39205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39206         this_ptr_conv.is_owned = false;
39207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39208         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
39209 }
39210
39211 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
39212         LDKScoringParameters this_ptr_conv;
39213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39214         this_ptr_conv.is_owned = false;
39215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39216         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
39217         return ret_val;
39218 }
39219
39220 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) {
39221         LDKScoringParameters this_ptr_conv;
39222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39223         this_ptr_conv.is_owned = false;
39224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39225         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
39226 }
39227
39228 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) {
39229         LDKScoringParameters this_ptr_conv;
39230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39231         this_ptr_conv.is_owned = false;
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39233         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
39234         return ret_val;
39235 }
39236
39237 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) {
39238         LDKScoringParameters this_ptr_conv;
39239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39240         this_ptr_conv.is_owned = false;
39241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39242         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
39243 }
39244
39245 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
39246         LDKScoringParameters this_ptr_conv;
39247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39248         this_ptr_conv.is_owned = false;
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39250         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
39251         return ret_val;
39252 }
39253
39254 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) {
39255         LDKScoringParameters this_ptr_conv;
39256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39257         this_ptr_conv.is_owned = false;
39258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39259         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
39260 }
39261
39262 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) {
39263         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);
39264         uint32_t ret_ref = 0;
39265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39268         ret_ref = (uintptr_t)ret_var.inner;
39269         if (ret_var.is_owned) {
39270                 ret_ref |= 1;
39271         }
39272         return ret_ref;
39273 }
39274
39275 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
39276         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
39277 uint32_t ret_ref = 0;
39278 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39279 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39280 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39281 ret_ref = (uintptr_t)ret_var.inner;
39282 if (ret_var.is_owned) {
39283         ret_ref |= 1;
39284 }
39285         return ret_ref;
39286 }
39287 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
39288         LDKScoringParameters arg_conv;
39289         arg_conv.inner = (void*)(arg & (~1));
39290         arg_conv.is_owned = false;
39291         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39292         uint32_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
39293         return ret_val;
39294 }
39295
39296 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
39297         LDKScoringParameters orig_conv;
39298         orig_conv.inner = (void*)(orig & (~1));
39299         orig_conv.is_owned = false;
39300         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39301         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
39302         uint32_t ret_ref = 0;
39303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39306         ret_ref = (uintptr_t)ret_var.inner;
39307         if (ret_var.is_owned) {
39308                 ret_ref |= 1;
39309         }
39310         return ret_ref;
39311 }
39312
39313 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
39314         LDKScoringParameters obj_conv;
39315         obj_conv.inner = (void*)(obj & (~1));
39316         obj_conv.is_owned = false;
39317         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39318         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
39319         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39320         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39321         CVec_u8Z_free(ret_var);
39322         return ret_arr;
39323 }
39324
39325 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
39326         LDKu8slice ser_ref;
39327         ser_ref.datalen = ser->arr_len;
39328         ser_ref.data = ser->elems /* XXX ser leaks */;
39329         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
39330         *ret_conv = ScoringParameters_read(ser_ref);
39331         return (uint32_t)ret_conv;
39332 }
39333
39334 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
39335         LDKScoringParameters params_conv;
39336         params_conv.inner = (void*)(params & (~1));
39337         params_conv.is_owned = (params & 1) || (params == 0);
39338         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39339         params_conv = ScoringParameters_clone(&params_conv);
39340         LDKScorer ret_var = Scorer_new(params_conv);
39341         uint32_t ret_ref = 0;
39342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39345         ret_ref = (uintptr_t)ret_var.inner;
39346         if (ret_var.is_owned) {
39347                 ret_ref |= 1;
39348         }
39349         return ret_ref;
39350 }
39351
39352 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
39353         LDKScorer ret_var = Scorer_default();
39354         uint32_t ret_ref = 0;
39355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39358         ret_ref = (uintptr_t)ret_var.inner;
39359         if (ret_var.is_owned) {
39360                 ret_ref |= 1;
39361         }
39362         return ret_ref;
39363 }
39364
39365 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
39366         LDKScoringParameters ret_var = ScoringParameters_default();
39367         uint32_t ret_ref = 0;
39368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39371         ret_ref = (uintptr_t)ret_var.inner;
39372         if (ret_var.is_owned) {
39373                 ret_ref |= 1;
39374         }
39375         return ret_ref;
39376 }
39377
39378 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
39379         LDKScorer this_arg_conv;
39380         this_arg_conv.inner = (void*)(this_arg & (~1));
39381         this_arg_conv.is_owned = false;
39382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39383         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39384         *ret_ret = Scorer_as_Score(&this_arg_conv);
39385         return (uint32_t)ret_ret;
39386 }
39387
39388 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
39389         LDKScorer obj_conv;
39390         obj_conv.inner = (void*)(obj & (~1));
39391         obj_conv.is_owned = false;
39392         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39393         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
39394         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39395         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39396         CVec_u8Z_free(ret_var);
39397         return ret_arr;
39398 }
39399
39400 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
39401         LDKu8slice ser_ref;
39402         ser_ref.datalen = ser->arr_len;
39403         ser_ref.data = ser->elems /* XXX ser leaks */;
39404         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
39405         *ret_conv = Scorer_read(ser_ref);
39406         return (uint32_t)ret_conv;
39407 }
39408
39409 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
39410         LDKProbabilisticScorer this_obj_conv;
39411         this_obj_conv.inner = (void*)(this_obj & (~1));
39412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39414         ProbabilisticScorer_free(this_obj_conv);
39415 }
39416
39417 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
39418         LDKProbabilisticScoringParameters this_obj_conv;
39419         this_obj_conv.inner = (void*)(this_obj & (~1));
39420         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39422         ProbabilisticScoringParameters_free(this_obj_conv);
39423 }
39424
39425 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39426         LDKProbabilisticScoringParameters this_ptr_conv;
39427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39428         this_ptr_conv.is_owned = false;
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39430         int64_t ret_val = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39431         return ret_val;
39432 }
39433
39434 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39435         LDKProbabilisticScoringParameters this_ptr_conv;
39436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39437         this_ptr_conv.is_owned = false;
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39439         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39440 }
39441
39442 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
39443         LDKProbabilisticScoringParameters this_ptr_conv;
39444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39445         this_ptr_conv.is_owned = false;
39446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39447         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
39448         return ret_val;
39449 }
39450
39451 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(uint32_t this_ptr, int64_t val) {
39452         LDKProbabilisticScoringParameters this_ptr_conv;
39453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39454         this_ptr_conv.is_owned = false;
39455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39456         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
39457 }
39458
39459 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
39460         LDKProbabilisticScoringParameters this_ptr_conv;
39461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39462         this_ptr_conv.is_owned = false;
39463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39464         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
39465         return ret_val;
39466 }
39467
39468 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life(uint32_t this_ptr, int64_t val) {
39469         LDKProbabilisticScoringParameters this_ptr_conv;
39470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39471         this_ptr_conv.is_owned = false;
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39473         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
39474 }
39475
39476 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
39477         LDKProbabilisticScoringParameters this_ptr_conv;
39478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39479         this_ptr_conv.is_owned = false;
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39481         int64_t ret_val = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
39482         return ret_val;
39483 }
39484
39485 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(uint32_t this_ptr, int64_t val) {
39486         LDKProbabilisticScoringParameters this_ptr_conv;
39487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39488         this_ptr_conv.is_owned = false;
39489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39490         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
39491 }
39492
39493 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_new"))) TS_ProbabilisticScoringParameters_new(int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
39494         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
39495         uint32_t ret_ref = 0;
39496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39499         ret_ref = (uintptr_t)ret_var.inner;
39500         if (ret_var.is_owned) {
39501                 ret_ref |= 1;
39502         }
39503         return ret_ref;
39504 }
39505
39506 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
39507         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
39508 uint32_t ret_ref = 0;
39509 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39510 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39511 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39512 ret_ref = (uintptr_t)ret_var.inner;
39513 if (ret_var.is_owned) {
39514         ret_ref |= 1;
39515 }
39516         return ret_ref;
39517 }
39518 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
39519         LDKProbabilisticScoringParameters arg_conv;
39520         arg_conv.inner = (void*)(arg & (~1));
39521         arg_conv.is_owned = false;
39522         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39523         uint32_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
39524         return ret_val;
39525 }
39526
39527 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
39528         LDKProbabilisticScoringParameters orig_conv;
39529         orig_conv.inner = (void*)(orig & (~1));
39530         orig_conv.is_owned = false;
39531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39532         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
39533         uint32_t ret_ref = 0;
39534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39537         ret_ref = (uintptr_t)ret_var.inner;
39538         if (ret_var.is_owned) {
39539                 ret_ref |= 1;
39540         }
39541         return ret_ref;
39542 }
39543
39544 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph) {
39545         LDKProbabilisticScoringParameters params_conv;
39546         params_conv.inner = (void*)(params & (~1));
39547         params_conv.is_owned = (params & 1) || (params == 0);
39548         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39549         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
39550         LDKNetworkGraph network_graph_conv;
39551         network_graph_conv.inner = (void*)(network_graph & (~1));
39552         network_graph_conv.is_owned = false;
39553         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39554         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
39555         uint32_t ret_ref = 0;
39556         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39557         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39559         ret_ref = (uintptr_t)ret_var.inner;
39560         if (ret_var.is_owned) {
39561                 ret_ref |= 1;
39562         }
39563         return ret_ref;
39564 }
39565
39566 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
39567         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
39568         uint32_t ret_ref = 0;
39569         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39570         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39572         ret_ref = (uintptr_t)ret_var.inner;
39573         if (ret_var.is_owned) {
39574                 ret_ref |= 1;
39575         }
39576         return ret_ref;
39577 }
39578
39579 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
39580         LDKProbabilisticScorer this_arg_conv;
39581         this_arg_conv.inner = (void*)(this_arg & (~1));
39582         this_arg_conv.is_owned = false;
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39584         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39585         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
39586         return (uint32_t)ret_ret;
39587 }
39588
39589 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
39590         LDKProbabilisticScorer obj_conv;
39591         obj_conv.inner = (void*)(obj & (~1));
39592         obj_conv.is_owned = false;
39593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39594         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
39595         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39596         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39597         CVec_u8Z_free(ret_var);
39598         return ret_arr;
39599 }
39600
39601 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b) {
39602         LDKu8slice ser_ref;
39603         ser_ref.datalen = ser->arr_len;
39604         ser_ref.data = ser->elems /* XXX ser leaks */;
39605         LDKProbabilisticScoringParameters arg_a_conv;
39606         arg_a_conv.inner = (void*)(arg_a & (~1));
39607         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
39608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
39609         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
39610         LDKNetworkGraph arg_b_conv;
39611         arg_b_conv.inner = (void*)(arg_b & (~1));
39612         arg_b_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
39614         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
39615         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
39616         return (uint32_t)ret_conv;
39617 }
39618
39619 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
39620         if ((this_ptr & 1) != 0) return;
39621         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39622         CHECK_ACCESS(this_ptr_ptr);
39623         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
39624         FREE((void*)this_ptr);
39625         ParseError_free(this_ptr_conv);
39626 }
39627
39628 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
39629         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39630         *ret_copy = ParseError_clone(arg);
39631 uint32_t ret_ref = (uintptr_t)ret_copy;
39632         return ret_ref;
39633 }
39634 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
39635         LDKParseError* arg_conv = (LDKParseError*)arg;
39636         uint32_t ret_val = ParseError_clone_ptr(arg_conv);
39637         return ret_val;
39638 }
39639
39640 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
39641         LDKParseError* orig_conv = (LDKParseError*)orig;
39642         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39643         *ret_copy = ParseError_clone(orig_conv);
39644         uint32_t ret_ref = (uintptr_t)ret_copy;
39645         return ret_ref;
39646 }
39647
39648 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
39649         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39650         CHECK_ACCESS(a_ptr);
39651         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
39652         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
39653         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39654         *ret_copy = ParseError_bech32_error(a_conv);
39655         uint32_t ret_ref = (uintptr_t)ret_copy;
39656         return ret_ref;
39657 }
39658
39659 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
39660         
39661         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39662         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
39663         uint32_t ret_ref = (uintptr_t)ret_copy;
39664         return ret_ref;
39665 }
39666
39667 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
39668         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
39669         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39670         *ret_copy = ParseError_malformed_signature(a_conv);
39671         uint32_t ret_ref = (uintptr_t)ret_copy;
39672         return ret_ref;
39673 }
39674
39675 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
39676         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39677         *ret_copy = ParseError_bad_prefix();
39678         uint32_t ret_ref = (uintptr_t)ret_copy;
39679         return ret_ref;
39680 }
39681
39682 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
39683         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39684         *ret_copy = ParseError_unknown_currency();
39685         uint32_t ret_ref = (uintptr_t)ret_copy;
39686         return ret_ref;
39687 }
39688
39689 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
39690         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39691         *ret_copy = ParseError_unknown_si_prefix();
39692         uint32_t ret_ref = (uintptr_t)ret_copy;
39693         return ret_ref;
39694 }
39695
39696 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
39697         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39698         *ret_copy = ParseError_malformed_hrp();
39699         uint32_t ret_ref = (uintptr_t)ret_copy;
39700         return ret_ref;
39701 }
39702
39703 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
39704         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39705         *ret_copy = ParseError_too_short_data_part();
39706         uint32_t ret_ref = (uintptr_t)ret_copy;
39707         return ret_ref;
39708 }
39709
39710 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
39711         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39712         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
39713         uint32_t ret_ref = (uintptr_t)ret_copy;
39714         return ret_ref;
39715 }
39716
39717 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
39718         
39719         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39720         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
39721         uint32_t ret_ref = (uintptr_t)ret_copy;
39722         return ret_ref;
39723 }
39724
39725 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
39726         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39727         *ret_copy = ParseError_padding_error();
39728         uint32_t ret_ref = (uintptr_t)ret_copy;
39729         return ret_ref;
39730 }
39731
39732 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
39733         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39734         *ret_copy = ParseError_integer_overflow_error();
39735         uint32_t ret_ref = (uintptr_t)ret_copy;
39736         return ret_ref;
39737 }
39738
39739 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
39740         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39741         *ret_copy = ParseError_invalid_seg_wit_program_length();
39742         uint32_t ret_ref = (uintptr_t)ret_copy;
39743         return ret_ref;
39744 }
39745
39746 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
39747         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39748         *ret_copy = ParseError_invalid_pub_key_hash_length();
39749         uint32_t ret_ref = (uintptr_t)ret_copy;
39750         return ret_ref;
39751 }
39752
39753 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
39754         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39755         *ret_copy = ParseError_invalid_script_hash_length();
39756         uint32_t ret_ref = (uintptr_t)ret_copy;
39757         return ret_ref;
39758 }
39759
39760 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
39761         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39762         *ret_copy = ParseError_invalid_recovery_id();
39763         uint32_t ret_ref = (uintptr_t)ret_copy;
39764         return ret_ref;
39765 }
39766
39767 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
39768         LDKStr a_conv = str_ref_to_owned_c(a);
39769         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39770         *ret_copy = ParseError_invalid_slice_length(a_conv);
39771         uint32_t ret_ref = (uintptr_t)ret_copy;
39772         return ret_ref;
39773 }
39774
39775 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
39776         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39777         *ret_copy = ParseError_skip();
39778         uint32_t ret_ref = (uintptr_t)ret_copy;
39779         return ret_ref;
39780 }
39781
39782 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
39783         if ((this_ptr & 1) != 0) return;
39784         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39785         CHECK_ACCESS(this_ptr_ptr);
39786         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
39787         FREE((void*)this_ptr);
39788         ParseOrSemanticError_free(this_ptr_conv);
39789 }
39790
39791 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
39792         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39793         *ret_copy = ParseOrSemanticError_clone(arg);
39794 uint32_t ret_ref = (uintptr_t)ret_copy;
39795         return ret_ref;
39796 }
39797 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
39798         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
39799         uint32_t ret_val = ParseOrSemanticError_clone_ptr(arg_conv);
39800         return ret_val;
39801 }
39802
39803 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
39804         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
39805         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39806         *ret_copy = ParseOrSemanticError_clone(orig_conv);
39807         uint32_t ret_ref = (uintptr_t)ret_copy;
39808         return ret_ref;
39809 }
39810
39811 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
39812         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39813         CHECK_ACCESS(a_ptr);
39814         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
39815         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
39816         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39817         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
39818         uint32_t ret_ref = (uintptr_t)ret_copy;
39819         return ret_ref;
39820 }
39821
39822 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
39823         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
39824         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39825         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
39826         uint32_t ret_ref = (uintptr_t)ret_copy;
39827         return ret_ref;
39828 }
39829
39830 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
39831         LDKInvoice this_obj_conv;
39832         this_obj_conv.inner = (void*)(this_obj & (~1));
39833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39835         Invoice_free(this_obj_conv);
39836 }
39837
39838 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
39839         LDKInvoice a_conv;
39840         a_conv.inner = (void*)(a & (~1));
39841         a_conv.is_owned = false;
39842         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39843         LDKInvoice b_conv;
39844         b_conv.inner = (void*)(b & (~1));
39845         b_conv.is_owned = false;
39846         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39847         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
39848         return ret_val;
39849 }
39850
39851 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39852         LDKInvoice ret_var = Invoice_clone(arg);
39853 uint32_t ret_ref = 0;
39854 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39855 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39856 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39857 ret_ref = (uintptr_t)ret_var.inner;
39858 if (ret_var.is_owned) {
39859         ret_ref |= 1;
39860 }
39861         return ret_ref;
39862 }
39863 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
39864         LDKInvoice arg_conv;
39865         arg_conv.inner = (void*)(arg & (~1));
39866         arg_conv.is_owned = false;
39867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39868         uint32_t ret_val = Invoice_clone_ptr(&arg_conv);
39869         return ret_val;
39870 }
39871
39872 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
39873         LDKInvoice orig_conv;
39874         orig_conv.inner = (void*)(orig & (~1));
39875         orig_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39877         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39878         uint32_t ret_ref = 0;
39879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39882         ret_ref = (uintptr_t)ret_var.inner;
39883         if (ret_var.is_owned) {
39884                 ret_ref |= 1;
39885         }
39886         return ret_ref;
39887 }
39888
39889 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
39890         LDKSignedRawInvoice this_obj_conv;
39891         this_obj_conv.inner = (void*)(this_obj & (~1));
39892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39894         SignedRawInvoice_free(this_obj_conv);
39895 }
39896
39897 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
39898         LDKSignedRawInvoice a_conv;
39899         a_conv.inner = (void*)(a & (~1));
39900         a_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39902         LDKSignedRawInvoice b_conv;
39903         b_conv.inner = (void*)(b & (~1));
39904         b_conv.is_owned = false;
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39906         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
39907         return ret_val;
39908 }
39909
39910 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39911         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39912 uint32_t ret_ref = 0;
39913 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39914 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39915 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39916 ret_ref = (uintptr_t)ret_var.inner;
39917 if (ret_var.is_owned) {
39918         ret_ref |= 1;
39919 }
39920         return ret_ref;
39921 }
39922 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
39923         LDKSignedRawInvoice arg_conv;
39924         arg_conv.inner = (void*)(arg & (~1));
39925         arg_conv.is_owned = false;
39926         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39927         uint32_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
39928         return ret_val;
39929 }
39930
39931 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39932         LDKSignedRawInvoice orig_conv;
39933         orig_conv.inner = (void*)(orig & (~1));
39934         orig_conv.is_owned = false;
39935         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39936         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39937         uint32_t ret_ref = 0;
39938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39941         ret_ref = (uintptr_t)ret_var.inner;
39942         if (ret_var.is_owned) {
39943                 ret_ref |= 1;
39944         }
39945         return ret_ref;
39946 }
39947
39948 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
39949         LDKRawInvoice this_obj_conv;
39950         this_obj_conv.inner = (void*)(this_obj & (~1));
39951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39953         RawInvoice_free(this_obj_conv);
39954 }
39955
39956 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
39957         LDKRawInvoice this_ptr_conv;
39958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39959         this_ptr_conv.is_owned = false;
39960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39961         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39962         uint32_t ret_ref = 0;
39963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39966         ret_ref = (uintptr_t)ret_var.inner;
39967         if (ret_var.is_owned) {
39968                 ret_ref |= 1;
39969         }
39970         return ret_ref;
39971 }
39972
39973 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
39974         LDKRawInvoice this_ptr_conv;
39975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39976         this_ptr_conv.is_owned = false;
39977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39978         LDKRawDataPart val_conv;
39979         val_conv.inner = (void*)(val & (~1));
39980         val_conv.is_owned = (val & 1) || (val == 0);
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39982         val_conv = RawDataPart_clone(&val_conv);
39983         RawInvoice_set_data(&this_ptr_conv, val_conv);
39984 }
39985
39986 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
39987         LDKRawInvoice a_conv;
39988         a_conv.inner = (void*)(a & (~1));
39989         a_conv.is_owned = false;
39990         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39991         LDKRawInvoice b_conv;
39992         b_conv.inner = (void*)(b & (~1));
39993         b_conv.is_owned = false;
39994         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39995         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39996         return ret_val;
39997 }
39998
39999 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
40000         LDKRawInvoice ret_var = RawInvoice_clone(arg);
40001 uint32_t ret_ref = 0;
40002 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40003 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40004 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40005 ret_ref = (uintptr_t)ret_var.inner;
40006 if (ret_var.is_owned) {
40007         ret_ref |= 1;
40008 }
40009         return ret_ref;
40010 }
40011 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
40012         LDKRawInvoice arg_conv;
40013         arg_conv.inner = (void*)(arg & (~1));
40014         arg_conv.is_owned = false;
40015         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40016         uint32_t ret_val = RawInvoice_clone_ptr(&arg_conv);
40017         return ret_val;
40018 }
40019
40020 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
40021         LDKRawInvoice orig_conv;
40022         orig_conv.inner = (void*)(orig & (~1));
40023         orig_conv.is_owned = false;
40024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40025         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
40026         uint32_t ret_ref = 0;
40027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40030         ret_ref = (uintptr_t)ret_var.inner;
40031         if (ret_var.is_owned) {
40032                 ret_ref |= 1;
40033         }
40034         return ret_ref;
40035 }
40036
40037 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
40038         LDKRawDataPart this_obj_conv;
40039         this_obj_conv.inner = (void*)(this_obj & (~1));
40040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40042         RawDataPart_free(this_obj_conv);
40043 }
40044
40045 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
40046         LDKRawDataPart this_ptr_conv;
40047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40048         this_ptr_conv.is_owned = false;
40049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40050         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
40051         uint32_t ret_ref = 0;
40052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40055         ret_ref = (uintptr_t)ret_var.inner;
40056         if (ret_var.is_owned) {
40057                 ret_ref |= 1;
40058         }
40059         return ret_ref;
40060 }
40061
40062 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
40063         LDKRawDataPart this_ptr_conv;
40064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40065         this_ptr_conv.is_owned = false;
40066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40067         LDKPositiveTimestamp val_conv;
40068         val_conv.inner = (void*)(val & (~1));
40069         val_conv.is_owned = (val & 1) || (val == 0);
40070         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40071         val_conv = PositiveTimestamp_clone(&val_conv);
40072         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
40073 }
40074
40075 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
40076         LDKRawDataPart a_conv;
40077         a_conv.inner = (void*)(a & (~1));
40078         a_conv.is_owned = false;
40079         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40080         LDKRawDataPart b_conv;
40081         b_conv.inner = (void*)(b & (~1));
40082         b_conv.is_owned = false;
40083         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40084         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
40085         return ret_val;
40086 }
40087
40088 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
40089         LDKRawDataPart ret_var = RawDataPart_clone(arg);
40090 uint32_t ret_ref = 0;
40091 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40092 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40093 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40094 ret_ref = (uintptr_t)ret_var.inner;
40095 if (ret_var.is_owned) {
40096         ret_ref |= 1;
40097 }
40098         return ret_ref;
40099 }
40100 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
40101         LDKRawDataPart arg_conv;
40102         arg_conv.inner = (void*)(arg & (~1));
40103         arg_conv.is_owned = false;
40104         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40105         uint32_t ret_val = RawDataPart_clone_ptr(&arg_conv);
40106         return ret_val;
40107 }
40108
40109 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
40110         LDKRawDataPart orig_conv;
40111         orig_conv.inner = (void*)(orig & (~1));
40112         orig_conv.is_owned = false;
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40114         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
40115         uint32_t ret_ref = 0;
40116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40119         ret_ref = (uintptr_t)ret_var.inner;
40120         if (ret_var.is_owned) {
40121                 ret_ref |= 1;
40122         }
40123         return ret_ref;
40124 }
40125
40126 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
40127         LDKPositiveTimestamp this_obj_conv;
40128         this_obj_conv.inner = (void*)(this_obj & (~1));
40129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40131         PositiveTimestamp_free(this_obj_conv);
40132 }
40133
40134 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
40135         LDKPositiveTimestamp a_conv;
40136         a_conv.inner = (void*)(a & (~1));
40137         a_conv.is_owned = false;
40138         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40139         LDKPositiveTimestamp b_conv;
40140         b_conv.inner = (void*)(b & (~1));
40141         b_conv.is_owned = false;
40142         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40143         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
40144         return ret_val;
40145 }
40146
40147 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
40148         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
40149 uint32_t ret_ref = 0;
40150 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40151 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40152 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40153 ret_ref = (uintptr_t)ret_var.inner;
40154 if (ret_var.is_owned) {
40155         ret_ref |= 1;
40156 }
40157         return ret_ref;
40158 }
40159 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
40160         LDKPositiveTimestamp arg_conv;
40161         arg_conv.inner = (void*)(arg & (~1));
40162         arg_conv.is_owned = false;
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40164         uint32_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
40165         return ret_val;
40166 }
40167
40168 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
40169         LDKPositiveTimestamp orig_conv;
40170         orig_conv.inner = (void*)(orig & (~1));
40171         orig_conv.is_owned = false;
40172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40173         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
40174         uint32_t ret_ref = 0;
40175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40178         ret_ref = (uintptr_t)ret_var.inner;
40179         if (ret_var.is_owned) {
40180                 ret_ref |= 1;
40181         }
40182         return ret_ref;
40183 }
40184
40185 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
40186         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
40187         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
40188         return ret_conv;
40189 }
40190
40191 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
40192         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
40193         return ret_conv;
40194 }
40195
40196 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
40197         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
40198         return ret_conv;
40199 }
40200
40201 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
40202         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
40203         return ret_conv;
40204 }
40205
40206 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
40207         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
40208         return ret_conv;
40209 }
40210
40211 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
40212         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
40213         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
40214         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
40215         return ret_val;
40216 }
40217
40218 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
40219         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
40220         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
40221         return ret_val;
40222 }
40223
40224 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
40225         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
40226         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
40227         return ret_conv;
40228 }
40229
40230 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
40231         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
40232         return ret_conv;
40233 }
40234
40235 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
40236         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
40237         return ret_conv;
40238 }
40239
40240 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
40241         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
40242         return ret_conv;
40243 }
40244
40245 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
40246         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
40247         return ret_conv;
40248 }
40249
40250 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
40251         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
40252         return ret_conv;
40253 }
40254
40255 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
40256         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40257         int64_t ret_val = Currency_hash(o_conv);
40258         return ret_val;
40259 }
40260
40261 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
40262         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
40263         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
40264         jboolean ret_val = Currency_eq(a_conv, b_conv);
40265         return ret_val;
40266 }
40267
40268 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
40269         LDKSha256 this_obj_conv;
40270         this_obj_conv.inner = (void*)(this_obj & (~1));
40271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40273         Sha256_free(this_obj_conv);
40274 }
40275
40276 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
40277         LDKSha256 ret_var = Sha256_clone(arg);
40278 uint32_t ret_ref = 0;
40279 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40280 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40281 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40282 ret_ref = (uintptr_t)ret_var.inner;
40283 if (ret_var.is_owned) {
40284         ret_ref |= 1;
40285 }
40286         return ret_ref;
40287 }
40288 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
40289         LDKSha256 arg_conv;
40290         arg_conv.inner = (void*)(arg & (~1));
40291         arg_conv.is_owned = false;
40292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40293         uint32_t ret_val = Sha256_clone_ptr(&arg_conv);
40294         return ret_val;
40295 }
40296
40297 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
40298         LDKSha256 orig_conv;
40299         orig_conv.inner = (void*)(orig & (~1));
40300         orig_conv.is_owned = false;
40301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40302         LDKSha256 ret_var = Sha256_clone(&orig_conv);
40303         uint32_t ret_ref = 0;
40304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40307         ret_ref = (uintptr_t)ret_var.inner;
40308         if (ret_var.is_owned) {
40309                 ret_ref |= 1;
40310         }
40311         return ret_ref;
40312 }
40313
40314 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
40315         LDKSha256 o_conv;
40316         o_conv.inner = (void*)(o & (~1));
40317         o_conv.is_owned = false;
40318         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40319         int64_t ret_val = Sha256_hash(&o_conv);
40320         return ret_val;
40321 }
40322
40323 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
40324         LDKSha256 a_conv;
40325         a_conv.inner = (void*)(a & (~1));
40326         a_conv.is_owned = false;
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40328         LDKSha256 b_conv;
40329         b_conv.inner = (void*)(b & (~1));
40330         b_conv.is_owned = false;
40331         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40332         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
40333         return ret_val;
40334 }
40335
40336 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
40337         LDKDescription this_obj_conv;
40338         this_obj_conv.inner = (void*)(this_obj & (~1));
40339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40341         Description_free(this_obj_conv);
40342 }
40343
40344 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
40345         LDKDescription ret_var = Description_clone(arg);
40346 uint32_t ret_ref = 0;
40347 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40348 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40350 ret_ref = (uintptr_t)ret_var.inner;
40351 if (ret_var.is_owned) {
40352         ret_ref |= 1;
40353 }
40354         return ret_ref;
40355 }
40356 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
40357         LDKDescription arg_conv;
40358         arg_conv.inner = (void*)(arg & (~1));
40359         arg_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40361         uint32_t ret_val = Description_clone_ptr(&arg_conv);
40362         return ret_val;
40363 }
40364
40365 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
40366         LDKDescription orig_conv;
40367         orig_conv.inner = (void*)(orig & (~1));
40368         orig_conv.is_owned = false;
40369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40370         LDKDescription ret_var = Description_clone(&orig_conv);
40371         uint32_t ret_ref = 0;
40372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40375         ret_ref = (uintptr_t)ret_var.inner;
40376         if (ret_var.is_owned) {
40377                 ret_ref |= 1;
40378         }
40379         return ret_ref;
40380 }
40381
40382 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
40383         LDKDescription o_conv;
40384         o_conv.inner = (void*)(o & (~1));
40385         o_conv.is_owned = false;
40386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40387         int64_t ret_val = Description_hash(&o_conv);
40388         return ret_val;
40389 }
40390
40391 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
40392         LDKDescription a_conv;
40393         a_conv.inner = (void*)(a & (~1));
40394         a_conv.is_owned = false;
40395         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40396         LDKDescription b_conv;
40397         b_conv.inner = (void*)(b & (~1));
40398         b_conv.is_owned = false;
40399         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40400         jboolean ret_val = Description_eq(&a_conv, &b_conv);
40401         return ret_val;
40402 }
40403
40404 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
40405         LDKPayeePubKey this_obj_conv;
40406         this_obj_conv.inner = (void*)(this_obj & (~1));
40407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40409         PayeePubKey_free(this_obj_conv);
40410 }
40411
40412 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
40413         LDKPayeePubKey this_ptr_conv;
40414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40415         this_ptr_conv.is_owned = false;
40416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40417         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40418         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
40419         return ret_arr;
40420 }
40421
40422 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
40423         LDKPayeePubKey this_ptr_conv;
40424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40425         this_ptr_conv.is_owned = false;
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40427         LDKPublicKey val_ref;
40428         CHECK(val->arr_len == 33);
40429         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40430         PayeePubKey_set_a(&this_ptr_conv, val_ref);
40431 }
40432
40433 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
40434         LDKPublicKey a_arg_ref;
40435         CHECK(a_arg->arr_len == 33);
40436         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
40437         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
40438         uint32_t ret_ref = 0;
40439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40442         ret_ref = (uintptr_t)ret_var.inner;
40443         if (ret_var.is_owned) {
40444                 ret_ref |= 1;
40445         }
40446         return ret_ref;
40447 }
40448
40449 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
40450         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
40451 uint32_t ret_ref = 0;
40452 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40453 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40454 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40455 ret_ref = (uintptr_t)ret_var.inner;
40456 if (ret_var.is_owned) {
40457         ret_ref |= 1;
40458 }
40459         return ret_ref;
40460 }
40461 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
40462         LDKPayeePubKey arg_conv;
40463         arg_conv.inner = (void*)(arg & (~1));
40464         arg_conv.is_owned = false;
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40466         uint32_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
40467         return ret_val;
40468 }
40469
40470 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
40471         LDKPayeePubKey orig_conv;
40472         orig_conv.inner = (void*)(orig & (~1));
40473         orig_conv.is_owned = false;
40474         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40475         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
40476         uint32_t ret_ref = 0;
40477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40480         ret_ref = (uintptr_t)ret_var.inner;
40481         if (ret_var.is_owned) {
40482                 ret_ref |= 1;
40483         }
40484         return ret_ref;
40485 }
40486
40487 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
40488         LDKPayeePubKey o_conv;
40489         o_conv.inner = (void*)(o & (~1));
40490         o_conv.is_owned = false;
40491         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40492         int64_t ret_val = PayeePubKey_hash(&o_conv);
40493         return ret_val;
40494 }
40495
40496 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
40497         LDKPayeePubKey a_conv;
40498         a_conv.inner = (void*)(a & (~1));
40499         a_conv.is_owned = false;
40500         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40501         LDKPayeePubKey b_conv;
40502         b_conv.inner = (void*)(b & (~1));
40503         b_conv.is_owned = false;
40504         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40505         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
40506         return ret_val;
40507 }
40508
40509 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
40510         LDKExpiryTime this_obj_conv;
40511         this_obj_conv.inner = (void*)(this_obj & (~1));
40512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40514         ExpiryTime_free(this_obj_conv);
40515 }
40516
40517 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
40518         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
40519 uint32_t ret_ref = 0;
40520 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40521 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40522 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40523 ret_ref = (uintptr_t)ret_var.inner;
40524 if (ret_var.is_owned) {
40525         ret_ref |= 1;
40526 }
40527         return ret_ref;
40528 }
40529 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
40530         LDKExpiryTime arg_conv;
40531         arg_conv.inner = (void*)(arg & (~1));
40532         arg_conv.is_owned = false;
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40534         uint32_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
40535         return ret_val;
40536 }
40537
40538 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
40539         LDKExpiryTime orig_conv;
40540         orig_conv.inner = (void*)(orig & (~1));
40541         orig_conv.is_owned = false;
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40543         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
40544         uint32_t ret_ref = 0;
40545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40548         ret_ref = (uintptr_t)ret_var.inner;
40549         if (ret_var.is_owned) {
40550                 ret_ref |= 1;
40551         }
40552         return ret_ref;
40553 }
40554
40555 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
40556         LDKExpiryTime o_conv;
40557         o_conv.inner = (void*)(o & (~1));
40558         o_conv.is_owned = false;
40559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40560         int64_t ret_val = ExpiryTime_hash(&o_conv);
40561         return ret_val;
40562 }
40563
40564 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
40565         LDKExpiryTime a_conv;
40566         a_conv.inner = (void*)(a & (~1));
40567         a_conv.is_owned = false;
40568         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40569         LDKExpiryTime b_conv;
40570         b_conv.inner = (void*)(b & (~1));
40571         b_conv.is_owned = false;
40572         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40573         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
40574         return ret_val;
40575 }
40576
40577 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
40578         LDKMinFinalCltvExpiry this_obj_conv;
40579         this_obj_conv.inner = (void*)(this_obj & (~1));
40580         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40582         MinFinalCltvExpiry_free(this_obj_conv);
40583 }
40584
40585 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
40586         LDKMinFinalCltvExpiry this_ptr_conv;
40587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40588         this_ptr_conv.is_owned = false;
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40590         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
40591         return ret_val;
40592 }
40593
40594 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
40595         LDKMinFinalCltvExpiry this_ptr_conv;
40596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40597         this_ptr_conv.is_owned = false;
40598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40599         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
40600 }
40601
40602 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
40603         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
40604         uint32_t ret_ref = 0;
40605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40608         ret_ref = (uintptr_t)ret_var.inner;
40609         if (ret_var.is_owned) {
40610                 ret_ref |= 1;
40611         }
40612         return ret_ref;
40613 }
40614
40615 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
40616         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
40617 uint32_t ret_ref = 0;
40618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40621 ret_ref = (uintptr_t)ret_var.inner;
40622 if (ret_var.is_owned) {
40623         ret_ref |= 1;
40624 }
40625         return ret_ref;
40626 }
40627 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
40628         LDKMinFinalCltvExpiry arg_conv;
40629         arg_conv.inner = (void*)(arg & (~1));
40630         arg_conv.is_owned = false;
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40632         uint32_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
40633         return ret_val;
40634 }
40635
40636 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
40637         LDKMinFinalCltvExpiry orig_conv;
40638         orig_conv.inner = (void*)(orig & (~1));
40639         orig_conv.is_owned = false;
40640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40641         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
40642         uint32_t ret_ref = 0;
40643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40646         ret_ref = (uintptr_t)ret_var.inner;
40647         if (ret_var.is_owned) {
40648                 ret_ref |= 1;
40649         }
40650         return ret_ref;
40651 }
40652
40653 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
40654         LDKMinFinalCltvExpiry o_conv;
40655         o_conv.inner = (void*)(o & (~1));
40656         o_conv.is_owned = false;
40657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40658         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
40659         return ret_val;
40660 }
40661
40662 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
40663         LDKMinFinalCltvExpiry a_conv;
40664         a_conv.inner = (void*)(a & (~1));
40665         a_conv.is_owned = false;
40666         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40667         LDKMinFinalCltvExpiry b_conv;
40668         b_conv.inner = (void*)(b & (~1));
40669         b_conv.is_owned = false;
40670         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40671         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
40672         return ret_val;
40673 }
40674
40675 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
40676         if ((this_ptr & 1) != 0) return;
40677         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40678         CHECK_ACCESS(this_ptr_ptr);
40679         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
40680         FREE((void*)this_ptr);
40681         Fallback_free(this_ptr_conv);
40682 }
40683
40684 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
40685         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40686         *ret_copy = Fallback_clone(arg);
40687 uint32_t ret_ref = (uintptr_t)ret_copy;
40688         return ret_ref;
40689 }
40690 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
40691         LDKFallback* arg_conv = (LDKFallback*)arg;
40692         uint32_t ret_val = Fallback_clone_ptr(arg_conv);
40693         return ret_val;
40694 }
40695
40696 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
40697         LDKFallback* orig_conv = (LDKFallback*)orig;
40698         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40699         *ret_copy = Fallback_clone(orig_conv);
40700         uint32_t ret_ref = (uintptr_t)ret_copy;
40701         return ret_ref;
40702 }
40703
40704 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
40705         
40706         LDKCVec_u8Z program_ref;
40707         program_ref.datalen = program->arr_len;
40708         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
40709         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
40710         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40711         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
40712         uint32_t ret_ref = (uintptr_t)ret_copy;
40713         return ret_ref;
40714 }
40715
40716 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
40717         LDKTwentyBytes a_ref;
40718         CHECK(a->arr_len == 20);
40719         memcpy(a_ref.data, a->elems, 20); FREE(a);
40720         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40721         *ret_copy = Fallback_pub_key_hash(a_ref);
40722         uint32_t ret_ref = (uintptr_t)ret_copy;
40723         return ret_ref;
40724 }
40725
40726 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
40727         LDKTwentyBytes a_ref;
40728         CHECK(a->arr_len == 20);
40729         memcpy(a_ref.data, a->elems, 20); FREE(a);
40730         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40731         *ret_copy = Fallback_script_hash(a_ref);
40732         uint32_t ret_ref = (uintptr_t)ret_copy;
40733         return ret_ref;
40734 }
40735
40736 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
40737         LDKFallback* o_conv = (LDKFallback*)o;
40738         int64_t ret_val = Fallback_hash(o_conv);
40739         return ret_val;
40740 }
40741
40742 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
40743         LDKFallback* a_conv = (LDKFallback*)a;
40744         LDKFallback* b_conv = (LDKFallback*)b;
40745         jboolean ret_val = Fallback_eq(a_conv, b_conv);
40746         return ret_val;
40747 }
40748
40749 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
40750         LDKInvoiceSignature this_obj_conv;
40751         this_obj_conv.inner = (void*)(this_obj & (~1));
40752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40754         InvoiceSignature_free(this_obj_conv);
40755 }
40756
40757 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
40758         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
40759 uint32_t ret_ref = 0;
40760 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40761 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40762 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40763 ret_ref = (uintptr_t)ret_var.inner;
40764 if (ret_var.is_owned) {
40765         ret_ref |= 1;
40766 }
40767         return ret_ref;
40768 }
40769 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
40770         LDKInvoiceSignature arg_conv;
40771         arg_conv.inner = (void*)(arg & (~1));
40772         arg_conv.is_owned = false;
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40774         uint32_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
40775         return ret_val;
40776 }
40777
40778 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
40779         LDKInvoiceSignature orig_conv;
40780         orig_conv.inner = (void*)(orig & (~1));
40781         orig_conv.is_owned = false;
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40783         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
40784         uint32_t ret_ref = 0;
40785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40788         ret_ref = (uintptr_t)ret_var.inner;
40789         if (ret_var.is_owned) {
40790                 ret_ref |= 1;
40791         }
40792         return ret_ref;
40793 }
40794
40795 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
40796         LDKInvoiceSignature a_conv;
40797         a_conv.inner = (void*)(a & (~1));
40798         a_conv.is_owned = false;
40799         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40800         LDKInvoiceSignature b_conv;
40801         b_conv.inner = (void*)(b & (~1));
40802         b_conv.is_owned = false;
40803         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40804         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
40805         return ret_val;
40806 }
40807
40808 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
40809         LDKPrivateRoute this_obj_conv;
40810         this_obj_conv.inner = (void*)(this_obj & (~1));
40811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40813         PrivateRoute_free(this_obj_conv);
40814 }
40815
40816 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
40817         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
40818 uint32_t ret_ref = 0;
40819 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40820 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40821 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40822 ret_ref = (uintptr_t)ret_var.inner;
40823 if (ret_var.is_owned) {
40824         ret_ref |= 1;
40825 }
40826         return ret_ref;
40827 }
40828 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
40829         LDKPrivateRoute arg_conv;
40830         arg_conv.inner = (void*)(arg & (~1));
40831         arg_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40833         uint32_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
40834         return ret_val;
40835 }
40836
40837 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
40838         LDKPrivateRoute orig_conv;
40839         orig_conv.inner = (void*)(orig & (~1));
40840         orig_conv.is_owned = false;
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40842         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40843         uint32_t ret_ref = 0;
40844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847         ret_ref = (uintptr_t)ret_var.inner;
40848         if (ret_var.is_owned) {
40849                 ret_ref |= 1;
40850         }
40851         return ret_ref;
40852 }
40853
40854 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
40855         LDKPrivateRoute o_conv;
40856         o_conv.inner = (void*)(o & (~1));
40857         o_conv.is_owned = false;
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40859         int64_t ret_val = PrivateRoute_hash(&o_conv);
40860         return ret_val;
40861 }
40862
40863 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
40864         LDKPrivateRoute a_conv;
40865         a_conv.inner = (void*)(a & (~1));
40866         a_conv.is_owned = false;
40867         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40868         LDKPrivateRoute b_conv;
40869         b_conv.inner = (void*)(b & (~1));
40870         b_conv.is_owned = false;
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40872         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
40873         return ret_val;
40874 }
40875
40876 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
40877         LDKSignedRawInvoice this_arg_conv;
40878         this_arg_conv.inner = (void*)(this_arg & (~1));
40879         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40881         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40882         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40883         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40884         return ((uint32_t)ret_conv);
40885 }
40886
40887 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
40888         LDKSignedRawInvoice this_arg_conv;
40889         this_arg_conv.inner = (void*)(this_arg & (~1));
40890         this_arg_conv.is_owned = false;
40891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40892         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40893         uint32_t ret_ref = 0;
40894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40897         ret_ref = (uintptr_t)ret_var.inner;
40898         if (ret_var.is_owned) {
40899                 ret_ref |= 1;
40900         }
40901         return ret_ref;
40902 }
40903
40904 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
40905         LDKSignedRawInvoice this_arg_conv;
40906         this_arg_conv.inner = (void*)(this_arg & (~1));
40907         this_arg_conv.is_owned = false;
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40909         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40910         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
40911         return ret_arr;
40912 }
40913
40914 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
40915         LDKSignedRawInvoice this_arg_conv;
40916         this_arg_conv.inner = (void*)(this_arg & (~1));
40917         this_arg_conv.is_owned = false;
40918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40919         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40920         uint32_t ret_ref = 0;
40921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40924         ret_ref = (uintptr_t)ret_var.inner;
40925         if (ret_var.is_owned) {
40926                 ret_ref |= 1;
40927         }
40928         return ret_ref;
40929 }
40930
40931 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40932         LDKSignedRawInvoice this_arg_conv;
40933         this_arg_conv.inner = (void*)(this_arg & (~1));
40934         this_arg_conv.is_owned = false;
40935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40936         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40937         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40938         return (uint32_t)ret_conv;
40939 }
40940
40941 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
40942         LDKSignedRawInvoice this_arg_conv;
40943         this_arg_conv.inner = (void*)(this_arg & (~1));
40944         this_arg_conv.is_owned = false;
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40946         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40947         return ret_val;
40948 }
40949
40950 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
40951         LDKRawInvoice this_arg_conv;
40952         this_arg_conv.inner = (void*)(this_arg & (~1));
40953         this_arg_conv.is_owned = false;
40954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40955         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40956         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
40957         return ret_arr;
40958 }
40959
40960 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
40961         LDKRawInvoice this_arg_conv;
40962         this_arg_conv.inner = (void*)(this_arg & (~1));
40963         this_arg_conv.is_owned = false;
40964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40965         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40966         uint32_t ret_ref = 0;
40967         if ((uintptr_t)ret_var.inner > 4096) {
40968                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40969                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40971                 ret_ref = (uintptr_t)ret_var.inner;
40972                 if (ret_var.is_owned) {
40973                         ret_ref |= 1;
40974                 }
40975         }
40976         return ret_ref;
40977 }
40978
40979 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
40980         LDKRawInvoice this_arg_conv;
40981         this_arg_conv.inner = (void*)(this_arg & (~1));
40982         this_arg_conv.is_owned = false;
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40984         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40985         uint32_t ret_ref = 0;
40986         if ((uintptr_t)ret_var.inner > 4096) {
40987                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40988                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40990                 ret_ref = (uintptr_t)ret_var.inner;
40991                 if (ret_var.is_owned) {
40992                         ret_ref |= 1;
40993                 }
40994         }
40995         return ret_ref;
40996 }
40997
40998 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
40999         LDKRawInvoice this_arg_conv;
41000         this_arg_conv.inner = (void*)(this_arg & (~1));
41001         this_arg_conv.is_owned = false;
41002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41003         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
41004         uint32_t ret_ref = 0;
41005         if ((uintptr_t)ret_var.inner > 4096) {
41006                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41007                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41009                 ret_ref = (uintptr_t)ret_var.inner;
41010                 if (ret_var.is_owned) {
41011                         ret_ref |= 1;
41012                 }
41013         }
41014         return ret_ref;
41015 }
41016
41017 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
41018         LDKRawInvoice this_arg_conv;
41019         this_arg_conv.inner = (void*)(this_arg & (~1));
41020         this_arg_conv.is_owned = false;
41021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41022         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
41023         uint32_t ret_ref = 0;
41024         if ((uintptr_t)ret_var.inner > 4096) {
41025                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41026                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41028                 ret_ref = (uintptr_t)ret_var.inner;
41029                 if (ret_var.is_owned) {
41030                         ret_ref |= 1;
41031                 }
41032         }
41033         return ret_ref;
41034 }
41035
41036 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
41037         LDKRawInvoice this_arg_conv;
41038         this_arg_conv.inner = (void*)(this_arg & (~1));
41039         this_arg_conv.is_owned = false;
41040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41041         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
41042         uint32_t ret_ref = 0;
41043         if ((uintptr_t)ret_var.inner > 4096) {
41044                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41045                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41047                 ret_ref = (uintptr_t)ret_var.inner;
41048                 if (ret_var.is_owned) {
41049                         ret_ref |= 1;
41050                 }
41051         }
41052         return ret_ref;
41053 }
41054
41055 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
41056         LDKRawInvoice this_arg_conv;
41057         this_arg_conv.inner = (void*)(this_arg & (~1));
41058         this_arg_conv.is_owned = false;
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41060         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
41061         uint32_t ret_ref = 0;
41062         if ((uintptr_t)ret_var.inner > 4096) {
41063                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41064                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41066                 ret_ref = (uintptr_t)ret_var.inner;
41067                 if (ret_var.is_owned) {
41068                         ret_ref |= 1;
41069                 }
41070         }
41071         return ret_ref;
41072 }
41073
41074 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
41075         LDKRawInvoice this_arg_conv;
41076         this_arg_conv.inner = (void*)(this_arg & (~1));
41077         this_arg_conv.is_owned = false;
41078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41079         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41080         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
41081         return ret_arr;
41082 }
41083
41084 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
41085         LDKRawInvoice this_arg_conv;
41086         this_arg_conv.inner = (void*)(this_arg & (~1));
41087         this_arg_conv.is_owned = false;
41088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41089         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
41090         uint32_t ret_ref = 0;
41091         if ((uintptr_t)ret_var.inner > 4096) {
41092                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41093                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41095                 ret_ref = (uintptr_t)ret_var.inner;
41096                 if (ret_var.is_owned) {
41097                         ret_ref |= 1;
41098                 }
41099         }
41100         return ret_ref;
41101 }
41102
41103 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
41104         LDKRawInvoice this_arg_conv;
41105         this_arg_conv.inner = (void*)(this_arg & (~1));
41106         this_arg_conv.is_owned = false;
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41108         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
41109         uint32_tArray ret_arr = NULL;
41110         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41111         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41112         for (size_t o = 0; o < ret_var.datalen; o++) {
41113                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41114                 uint32_t ret_conv_14_ref = 0;
41115                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41116                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41117                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41118                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41119                 if (ret_conv_14_var.is_owned) {
41120                         ret_conv_14_ref |= 1;
41121                 }
41122                 ret_arr_ptr[o] = ret_conv_14_ref;
41123         }
41124         
41125         FREE(ret_var.data);
41126         return ret_arr;
41127 }
41128
41129 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
41130         LDKRawInvoice this_arg_conv;
41131         this_arg_conv.inner = (void*)(this_arg & (~1));
41132         this_arg_conv.is_owned = false;
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41134         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41135         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
41136         uint32_t ret_ref = (uintptr_t)ret_copy;
41137         return ret_ref;
41138 }
41139
41140 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
41141         LDKRawInvoice this_arg_conv;
41142         this_arg_conv.inner = (void*)(this_arg & (~1));
41143         this_arg_conv.is_owned = false;
41144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41145         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
41146         return ret_conv;
41147 }
41148
41149 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
41150         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41151         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
41152         return (uint32_t)ret_conv;
41153 }
41154
41155 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
41156         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41157         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
41158         return (uint32_t)ret_conv;
41159 }
41160
41161 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
41162         LDKPositiveTimestamp this_arg_conv;
41163         this_arg_conv.inner = (void*)(this_arg & (~1));
41164         this_arg_conv.is_owned = false;
41165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41166         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
41167         return ret_val;
41168 }
41169
41170 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
41171         LDKPositiveTimestamp this_arg_conv;
41172         this_arg_conv.inner = (void*)(this_arg & (~1));
41173         this_arg_conv.is_owned = false;
41174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41175         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
41176         return ret_val;
41177 }
41178
41179 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
41180         LDKInvoice this_arg_conv;
41181         this_arg_conv.inner = (void*)(this_arg & (~1));
41182         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41184         this_arg_conv = Invoice_clone(&this_arg_conv);
41185         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
41186         uint32_t ret_ref = 0;
41187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41190         ret_ref = (uintptr_t)ret_var.inner;
41191         if (ret_var.is_owned) {
41192                 ret_ref |= 1;
41193         }
41194         return ret_ref;
41195 }
41196
41197 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
41198         LDKInvoice this_arg_conv;
41199         this_arg_conv.inner = (void*)(this_arg & (~1));
41200         this_arg_conv.is_owned = false;
41201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41202         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
41203         *ret_conv = Invoice_check_signature(&this_arg_conv);
41204         return (uint32_t)ret_conv;
41205 }
41206
41207 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
41208         LDKSignedRawInvoice signed_invoice_conv;
41209         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
41210         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
41211         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
41212         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
41213         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
41214         *ret_conv = Invoice_from_signed(signed_invoice_conv);
41215         return (uint32_t)ret_conv;
41216 }
41217
41218 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
41219         LDKInvoice this_arg_conv;
41220         this_arg_conv.inner = (void*)(this_arg & (~1));
41221         this_arg_conv.is_owned = false;
41222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41223         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
41224         return ret_val;
41225 }
41226
41227 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
41228         LDKInvoice this_arg_conv;
41229         this_arg_conv.inner = (void*)(this_arg & (~1));
41230         this_arg_conv.is_owned = false;
41231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41232         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41233         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
41234         return ret_arr;
41235 }
41236
41237 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
41238         LDKInvoice this_arg_conv;
41239         this_arg_conv.inner = (void*)(this_arg & (~1));
41240         this_arg_conv.is_owned = false;
41241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41242         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41243         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
41244         return ret_arr;
41245 }
41246
41247 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
41248         LDKInvoice this_arg_conv;
41249         this_arg_conv.inner = (void*)(this_arg & (~1));
41250         this_arg_conv.is_owned = false;
41251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41252         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41253         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
41254         return ret_arr;
41255 }
41256
41257 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
41258         LDKInvoice this_arg_conv;
41259         this_arg_conv.inner = (void*)(this_arg & (~1));
41260         this_arg_conv.is_owned = false;
41261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41262         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
41263         uint32_t ret_ref = 0;
41264         if ((uintptr_t)ret_var.inner > 4096) {
41265                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41266                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41268                 ret_ref = (uintptr_t)ret_var.inner;
41269                 if (ret_var.is_owned) {
41270                         ret_ref |= 1;
41271                 }
41272         }
41273         return ret_ref;
41274 }
41275
41276 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
41277         LDKInvoice this_arg_conv;
41278         this_arg_conv.inner = (void*)(this_arg & (~1));
41279         this_arg_conv.is_owned = false;
41280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41281         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41282         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
41283         return ret_arr;
41284 }
41285
41286 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
41287         LDKInvoice this_arg_conv;
41288         this_arg_conv.inner = (void*)(this_arg & (~1));
41289         this_arg_conv.is_owned = false;
41290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41291         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
41292         return ret_val;
41293 }
41294
41295 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
41296         LDKInvoice this_arg_conv;
41297         this_arg_conv.inner = (void*)(this_arg & (~1));
41298         this_arg_conv.is_owned = false;
41299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41300         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
41301         return ret_val;
41302 }
41303
41304 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
41305         LDKInvoice this_arg_conv;
41306         this_arg_conv.inner = (void*)(this_arg & (~1));
41307         this_arg_conv.is_owned = false;
41308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41309         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
41310         return ret_val;
41311 }
41312
41313 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
41314         LDKInvoice this_arg_conv;
41315         this_arg_conv.inner = (void*)(this_arg & (~1));
41316         this_arg_conv.is_owned = false;
41317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41318         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
41319         uint32_tArray ret_arr = NULL;
41320         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41321         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41322         for (size_t o = 0; o < ret_var.datalen; o++) {
41323                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41324                 uint32_t ret_conv_14_ref = 0;
41325                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41326                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41327                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41328                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41329                 if (ret_conv_14_var.is_owned) {
41330                         ret_conv_14_ref |= 1;
41331                 }
41332                 ret_arr_ptr[o] = ret_conv_14_ref;
41333         }
41334         
41335         FREE(ret_var.data);
41336         return ret_arr;
41337 }
41338
41339 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
41340         LDKInvoice this_arg_conv;
41341         this_arg_conv.inner = (void*)(this_arg & (~1));
41342         this_arg_conv.is_owned = false;
41343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41344         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
41345         uint32_tArray ret_arr = NULL;
41346         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41347         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41348         for (size_t l = 0; l < ret_var.datalen; l++) {
41349                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41350                 uint32_t ret_conv_11_ref = 0;
41351                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41352                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41353                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41354                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41355                 if (ret_conv_11_var.is_owned) {
41356                         ret_conv_11_ref |= 1;
41357                 }
41358                 ret_arr_ptr[l] = ret_conv_11_ref;
41359         }
41360         
41361         FREE(ret_var.data);
41362         return ret_arr;
41363 }
41364
41365 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
41366         LDKInvoice this_arg_conv;
41367         this_arg_conv.inner = (void*)(this_arg & (~1));
41368         this_arg_conv.is_owned = false;
41369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41370         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
41371         return ret_conv;
41372 }
41373
41374 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
41375         LDKInvoice this_arg_conv;
41376         this_arg_conv.inner = (void*)(this_arg & (~1));
41377         this_arg_conv.is_owned = false;
41378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41379         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41380         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
41381         uint32_t ret_ref = (uintptr_t)ret_copy;
41382         return ret_ref;
41383 }
41384
41385 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
41386         LDKStr description_conv = str_ref_to_owned_c(description);
41387         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
41388         *ret_conv = Description_new(description_conv);
41389         return (uint32_t)ret_conv;
41390 }
41391
41392 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
41393         LDKDescription this_arg_conv;
41394         this_arg_conv.inner = (void*)(this_arg & (~1));
41395         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41397         this_arg_conv = Description_clone(&this_arg_conv);
41398         LDKStr ret_str = Description_into_inner(this_arg_conv);
41399         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41400         Str_free(ret_str);
41401         return ret_conv;
41402 }
41403
41404 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
41405         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
41406         uint32_t ret_ref = 0;
41407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41410         ret_ref = (uintptr_t)ret_var.inner;
41411         if (ret_var.is_owned) {
41412                 ret_ref |= 1;
41413         }
41414         return ret_ref;
41415 }
41416
41417 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
41418         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
41419         uint32_t ret_ref = 0;
41420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41423         ret_ref = (uintptr_t)ret_var.inner;
41424         if (ret_var.is_owned) {
41425                 ret_ref |= 1;
41426         }
41427         return ret_ref;
41428 }
41429
41430 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
41431         LDKExpiryTime this_arg_conv;
41432         this_arg_conv.inner = (void*)(this_arg & (~1));
41433         this_arg_conv.is_owned = false;
41434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41435         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
41436         return ret_val;
41437 }
41438
41439 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
41440         LDKExpiryTime this_arg_conv;
41441         this_arg_conv.inner = (void*)(this_arg & (~1));
41442         this_arg_conv.is_owned = false;
41443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41444         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
41445         return ret_val;
41446 }
41447
41448 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
41449         LDKRouteHint hops_conv;
41450         hops_conv.inner = (void*)(hops & (~1));
41451         hops_conv.is_owned = (hops & 1) || (hops == 0);
41452         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
41453         hops_conv = RouteHint_clone(&hops_conv);
41454         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
41455         *ret_conv = PrivateRoute_new(hops_conv);
41456         return (uint32_t)ret_conv;
41457 }
41458
41459 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
41460         LDKPrivateRoute this_arg_conv;
41461         this_arg_conv.inner = (void*)(this_arg & (~1));
41462         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41464         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
41465         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
41466         uint32_t ret_ref = 0;
41467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41470         ret_ref = (uintptr_t)ret_var.inner;
41471         if (ret_var.is_owned) {
41472                 ret_ref |= 1;
41473         }
41474         return ret_ref;
41475 }
41476
41477 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
41478         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
41479         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
41480         return ret_conv;
41481 }
41482
41483 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
41484         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
41485         return ret_conv;
41486 }
41487
41488 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
41489         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
41490         return ret_conv;
41491 }
41492
41493 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
41494         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
41495         return ret_conv;
41496 }
41497
41498 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
41499         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
41500         return ret_conv;
41501 }
41502
41503 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
41504         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
41505         return ret_conv;
41506 }
41507
41508 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
41509         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
41510         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
41511         jboolean ret_val = CreationError_eq(a_conv, b_conv);
41512         return ret_val;
41513 }
41514
41515 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
41516         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
41517         LDKStr ret_str = CreationError_to_str(o_conv);
41518         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41519         Str_free(ret_str);
41520         return ret_conv;
41521 }
41522
41523 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
41524         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
41525         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
41526         return ret_conv;
41527 }
41528
41529 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
41530         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
41531         return ret_conv;
41532 }
41533
41534 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
41535         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
41536         return ret_conv;
41537 }
41538
41539 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
41540         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
41541         return ret_conv;
41542 }
41543
41544 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
41545         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
41546         return ret_conv;
41547 }
41548
41549 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
41550         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
41551         return ret_conv;
41552 }
41553
41554 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
41555         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
41556         return ret_conv;
41557 }
41558
41559 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
41560         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
41561         return ret_conv;
41562 }
41563
41564 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
41565         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
41566         return ret_conv;
41567 }
41568
41569 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
41570         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
41571         return ret_conv;
41572 }
41573
41574 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
41575         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
41576         return ret_conv;
41577 }
41578
41579 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
41580         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
41581         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
41582         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
41583         return ret_val;
41584 }
41585
41586 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
41587         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
41588         LDKStr ret_str = SemanticError_to_str(o_conv);
41589         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41590         Str_free(ret_str);
41591         return ret_conv;
41592 }
41593
41594 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
41595         if ((this_ptr & 1) != 0) return;
41596         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41597         CHECK_ACCESS(this_ptr_ptr);
41598         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
41599         FREE((void*)this_ptr);
41600         SignOrCreationError_free(this_ptr_conv);
41601 }
41602
41603 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
41604         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41605         *ret_copy = SignOrCreationError_clone(arg);
41606 uint32_t ret_ref = (uintptr_t)ret_copy;
41607         return ret_ref;
41608 }
41609 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
41610         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
41611         uint32_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
41612         return ret_val;
41613 }
41614
41615 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
41616         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
41617         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41618         *ret_copy = SignOrCreationError_clone(orig_conv);
41619         uint32_t ret_ref = (uintptr_t)ret_copy;
41620         return ret_ref;
41621 }
41622
41623 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
41624         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41625         *ret_copy = SignOrCreationError_sign_error();
41626         uint32_t ret_ref = (uintptr_t)ret_copy;
41627         return ret_ref;
41628 }
41629
41630 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
41631         LDKCreationError a_conv = LDKCreationError_from_js(a);
41632         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41633         *ret_copy = SignOrCreationError_creation_error(a_conv);
41634         uint32_t ret_ref = (uintptr_t)ret_copy;
41635         return ret_ref;
41636 }
41637
41638 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
41639         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
41640         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
41641         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
41642         return ret_val;
41643 }
41644
41645 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
41646         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
41647         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
41648         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41649         Str_free(ret_str);
41650         return ret_conv;
41651 }
41652
41653 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
41654         LDKInvoicePayer this_obj_conv;
41655         this_obj_conv.inner = (void*)(this_obj & (~1));
41656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41658         InvoicePayer_free(this_obj_conv);
41659 }
41660
41661 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
41662         if ((this_ptr & 1) != 0) return;
41663         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41664         CHECK_ACCESS(this_ptr_ptr);
41665         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
41666         FREE((void*)this_ptr);
41667         Payer_free(this_ptr_conv);
41668 }
41669
41670 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
41671         if ((this_ptr & 1) != 0) return;
41672         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41673         CHECK_ACCESS(this_ptr_ptr);
41674         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
41675         FREE((void*)this_ptr);
41676         Router_free(this_ptr_conv);
41677 }
41678
41679 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
41680         LDKRetryAttempts this_obj_conv;
41681         this_obj_conv.inner = (void*)(this_obj & (~1));
41682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41684         RetryAttempts_free(this_obj_conv);
41685 }
41686
41687 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
41688         LDKRetryAttempts this_ptr_conv;
41689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41690         this_ptr_conv.is_owned = false;
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41692         uint32_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
41693         return ret_val;
41694 }
41695
41696 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
41697         LDKRetryAttempts this_ptr_conv;
41698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41699         this_ptr_conv.is_owned = false;
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41701         RetryAttempts_set_a(&this_ptr_conv, val);
41702 }
41703
41704 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
41705         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
41706         uint32_t ret_ref = 0;
41707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41710         ret_ref = (uintptr_t)ret_var.inner;
41711         if (ret_var.is_owned) {
41712                 ret_ref |= 1;
41713         }
41714         return ret_ref;
41715 }
41716
41717 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
41718         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
41719 uint32_t ret_ref = 0;
41720 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41721 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41722 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41723 ret_ref = (uintptr_t)ret_var.inner;
41724 if (ret_var.is_owned) {
41725         ret_ref |= 1;
41726 }
41727         return ret_ref;
41728 }
41729 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
41730         LDKRetryAttempts arg_conv;
41731         arg_conv.inner = (void*)(arg & (~1));
41732         arg_conv.is_owned = false;
41733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41734         uint32_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
41735         return ret_val;
41736 }
41737
41738 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
41739         LDKRetryAttempts orig_conv;
41740         orig_conv.inner = (void*)(orig & (~1));
41741         orig_conv.is_owned = false;
41742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41743         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
41744         uint32_t ret_ref = 0;
41745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41748         ret_ref = (uintptr_t)ret_var.inner;
41749         if (ret_var.is_owned) {
41750                 ret_ref |= 1;
41751         }
41752         return ret_ref;
41753 }
41754
41755 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
41756         LDKRetryAttempts a_conv;
41757         a_conv.inner = (void*)(a & (~1));
41758         a_conv.is_owned = false;
41759         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41760         LDKRetryAttempts b_conv;
41761         b_conv.inner = (void*)(b & (~1));
41762         b_conv.is_owned = false;
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41764         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
41765         return ret_val;
41766 }
41767
41768 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
41769         LDKRetryAttempts o_conv;
41770         o_conv.inner = (void*)(o & (~1));
41771         o_conv.is_owned = false;
41772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41773         int64_t ret_val = RetryAttempts_hash(&o_conv);
41774         return ret_val;
41775 }
41776
41777 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
41778         if ((this_ptr & 1) != 0) return;
41779         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41780         CHECK_ACCESS(this_ptr_ptr);
41781         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
41782         FREE((void*)this_ptr);
41783         PaymentError_free(this_ptr_conv);
41784 }
41785
41786 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
41787         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41788         *ret_copy = PaymentError_clone(arg);
41789 uint32_t ret_ref = (uintptr_t)ret_copy;
41790         return ret_ref;
41791 }
41792 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
41793         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
41794         uint32_t ret_val = PaymentError_clone_ptr(arg_conv);
41795         return ret_val;
41796 }
41797
41798 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
41799         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
41800         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41801         *ret_copy = PaymentError_clone(orig_conv);
41802         uint32_t ret_ref = (uintptr_t)ret_copy;
41803         return ret_ref;
41804 }
41805
41806 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
41807         LDKStr a_conv = str_ref_to_owned_c(a);
41808         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41809         *ret_copy = PaymentError_invoice(a_conv);
41810         uint32_t ret_ref = (uintptr_t)ret_copy;
41811         return ret_ref;
41812 }
41813
41814 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
41815         LDKLightningError a_conv;
41816         a_conv.inner = (void*)(a & (~1));
41817         a_conv.is_owned = (a & 1) || (a == 0);
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41819         a_conv = LightningError_clone(&a_conv);
41820         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41821         *ret_copy = PaymentError_routing(a_conv);
41822         uint32_t ret_ref = (uintptr_t)ret_copy;
41823         return ret_ref;
41824 }
41825
41826 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
41827         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41828         CHECK_ACCESS(a_ptr);
41829         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
41830         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
41831         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41832         *ret_copy = PaymentError_sending(a_conv);
41833         uint32_t ret_ref = (uintptr_t)ret_copy;
41834         return ret_ref;
41835 }
41836
41837 uint32_t  __attribute__((export_name("TS_InvoicePayer_new"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
41838         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
41839         CHECK_ACCESS(payer_ptr);
41840         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
41841         if (payer_conv.free == LDKPayer_JCalls_free) {
41842                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41843                 LDKPayer_JCalls_cloned(&payer_conv);
41844         }
41845         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
41846         CHECK_ACCESS(router_ptr);
41847         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
41848         if (router_conv.free == LDKRouter_JCalls_free) {
41849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41850                 LDKRouter_JCalls_cloned(&router_conv);
41851         }
41852         LDKMultiThreadedLockableScore scorer_conv;
41853         scorer_conv.inner = (void*)(scorer & (~1));
41854         scorer_conv.is_owned = false;
41855         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41856         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41857         CHECK_ACCESS(logger_ptr);
41858         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41859         if (logger_conv.free == LDKLogger_JCalls_free) {
41860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41861                 LDKLogger_JCalls_cloned(&logger_conv);
41862         }
41863         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
41864         CHECK_ACCESS(event_handler_ptr);
41865         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41866         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
41867                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41868                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
41869         }
41870         LDKRetryAttempts retry_attempts_conv;
41871         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41872         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41873         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41874         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41875         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41876         uint32_t ret_ref = 0;
41877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41880         ret_ref = (uintptr_t)ret_var.inner;
41881         if (ret_var.is_owned) {
41882                 ret_ref |= 1;
41883         }
41884         return ret_ref;
41885 }
41886
41887 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
41888         LDKInvoicePayer this_arg_conv;
41889         this_arg_conv.inner = (void*)(this_arg & (~1));
41890         this_arg_conv.is_owned = false;
41891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41892         LDKInvoice invoice_conv;
41893         invoice_conv.inner = (void*)(invoice & (~1));
41894         invoice_conv.is_owned = false;
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41896         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41897         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41898         return (uint32_t)ret_conv;
41899 }
41900
41901 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_zero_value_invoice"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
41902         LDKInvoicePayer this_arg_conv;
41903         this_arg_conv.inner = (void*)(this_arg & (~1));
41904         this_arg_conv.is_owned = false;
41905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41906         LDKInvoice invoice_conv;
41907         invoice_conv.inner = (void*)(invoice & (~1));
41908         invoice_conv.is_owned = false;
41909         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41910         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41911         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41912         return (uint32_t)ret_conv;
41913 }
41914
41915 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_pubkey"))) TS_InvoicePayer_pay_pubkey(uint32_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
41916         LDKInvoicePayer this_arg_conv;
41917         this_arg_conv.inner = (void*)(this_arg & (~1));
41918         this_arg_conv.is_owned = false;
41919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41920         LDKPublicKey pubkey_ref;
41921         CHECK(pubkey->arr_len == 33);
41922         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41923         LDKThirtyTwoBytes payment_preimage_ref;
41924         CHECK(payment_preimage->arr_len == 32);
41925         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
41926         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41927         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41928         return (uint32_t)ret_conv;
41929 }
41930
41931 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
41932         LDKInvoicePayer this_arg_conv;
41933         this_arg_conv.inner = (void*)(this_arg & (~1));
41934         this_arg_conv.is_owned = false;
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41936         unsigned char payment_hash_arr[32];
41937         CHECK(payment_hash->arr_len == 32);
41938         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
41939         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
41940         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
41941 }
41942
41943 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
41944         LDKInvoicePayer this_arg_conv;
41945         this_arg_conv.inner = (void*)(this_arg & (~1));
41946         this_arg_conv.is_owned = false;
41947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41948         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41949         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41950         return (uint32_t)ret_ret;
41951 }
41952
41953 uint32_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, uint32_t description_hash, int64_t duration_since_epoch) {
41954         LDKChannelManager channelmanager_conv;
41955         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41956         channelmanager_conv.is_owned = false;
41957         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41958         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41959         CHECK_ACCESS(keys_manager_ptr);
41960         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41961         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
41962                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41963                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
41964         }
41965         LDKCurrency network_conv = LDKCurrency_from_js(network);
41966         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41967         CHECK_ACCESS(amt_msat_ptr);
41968         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41969         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41970         LDKSha256 description_hash_conv;
41971         description_hash_conv.inner = (void*)(description_hash & (~1));
41972         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
41974         description_hash_conv = Sha256_clone(&description_hash_conv);
41975         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41976         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch);
41977         return (uint32_t)ret_conv;
41978 }
41979
41980 uint32_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_and_duration_since_epoch(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description, int64_t duration_since_epoch) {
41981         LDKChannelManager channelmanager_conv;
41982         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41983         channelmanager_conv.is_owned = false;
41984         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41985         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41986         CHECK_ACCESS(keys_manager_ptr);
41987         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41988         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
41989                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41990                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
41991         }
41992         LDKCurrency network_conv = LDKCurrency_from_js(network);
41993         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41994         CHECK_ACCESS(amt_msat_ptr);
41995         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41996         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41997         LDKStr description_conv = str_ref_to_owned_c(description);
41998         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41999         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch);
42000         return (uint32_t)ret_conv;
42001 }
42002
42003 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
42004         LDKDefaultRouter this_obj_conv;
42005         this_obj_conv.inner = (void*)(this_obj & (~1));
42006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42008         DefaultRouter_free(this_obj_conv);
42009 }
42010
42011 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42012         LDKNetworkGraph network_graph_conv;
42013         network_graph_conv.inner = (void*)(network_graph & (~1));
42014         network_graph_conv.is_owned = false;
42015         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42016         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42017         CHECK_ACCESS(logger_ptr);
42018         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42019         if (logger_conv.free == LDKLogger_JCalls_free) {
42020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42021                 LDKLogger_JCalls_cloned(&logger_conv);
42022         }
42023         LDKThirtyTwoBytes random_seed_bytes_ref;
42024         CHECK(random_seed_bytes->arr_len == 32);
42025         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42026         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
42027         uint32_t ret_ref = 0;
42028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42031         ret_ref = (uintptr_t)ret_var.inner;
42032         if (ret_var.is_owned) {
42033                 ret_ref |= 1;
42034         }
42035         return ret_ref;
42036 }
42037
42038 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
42039         LDKDefaultRouter this_arg_conv;
42040         this_arg_conv.inner = (void*)(this_arg & (~1));
42041         this_arg_conv.is_owned = false;
42042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42043         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
42044         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
42045         return (uint32_t)ret_ret;
42046 }
42047
42048 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
42049         LDKChannelManager this_arg_conv;
42050         this_arg_conv.inner = (void*)(this_arg & (~1));
42051         this_arg_conv.is_owned = false;
42052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42053         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
42054         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
42055         return (uint32_t)ret_ret;
42056 }
42057
42058 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
42059         LDKStr s_conv = str_ref_to_owned_c(s);
42060         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
42061         *ret_conv = SiPrefix_from_str(s_conv);
42062         return (uint32_t)ret_conv;
42063 }
42064
42065 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
42066         LDKStr s_conv = str_ref_to_owned_c(s);
42067         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
42068         *ret_conv = Invoice_from_str(s_conv);
42069         return (uint32_t)ret_conv;
42070 }
42071
42072 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
42073         LDKStr s_conv = str_ref_to_owned_c(s);
42074         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
42075         *ret_conv = SignedRawInvoice_from_str(s_conv);
42076         return (uint32_t)ret_conv;
42077 }
42078
42079 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
42080         LDKParseError* o_conv = (LDKParseError*)o;
42081         LDKStr ret_str = ParseError_to_str(o_conv);
42082         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42083         Str_free(ret_str);
42084         return ret_conv;
42085 }
42086
42087 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
42088         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
42089         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
42090         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42091         Str_free(ret_str);
42092         return ret_conv;
42093 }
42094
42095 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
42096         LDKInvoice o_conv;
42097         o_conv.inner = (void*)(o & (~1));
42098         o_conv.is_owned = false;
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42100         LDKStr ret_str = Invoice_to_str(&o_conv);
42101         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42102         Str_free(ret_str);
42103         return ret_conv;
42104 }
42105
42106 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
42107         LDKSignedRawInvoice o_conv;
42108         o_conv.inner = (void*)(o & (~1));
42109         o_conv.is_owned = false;
42110         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42111         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
42112         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42113         Str_free(ret_str);
42114         return ret_conv;
42115 }
42116
42117 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
42118         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42119         LDKStr ret_str = Currency_to_str(o_conv);
42120         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42121         Str_free(ret_str);
42122         return ret_conv;
42123 }
42124
42125 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
42126         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
42127         LDKStr ret_str = SiPrefix_to_str(o_conv);
42128         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42129         Str_free(ret_str);
42130         return ret_conv;
42131 }
42132